react-native-fxdialog 1.0.0-beta05 → 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,15 +39,27 @@ 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;
42
53
  /**
43
- * 添加背景样式
54
+ * 设置背景样式
44
55
  */
45
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;
46
63
  /**
47
64
  * 设置容器样式
48
65
  */
@@ -79,7 +96,7 @@ declare class FXDialog {
79
96
  */
80
97
  containerScrollMaxHeight(maxHeight: number): this;
81
98
  /**
82
- * 设置按钮区最小高度
99
+ * 设置弹窗需要滚动时按钮区最小高度
83
100
  * @param minHeight 最小高度
84
101
  */
85
102
  actionsScrollMinHeight(minHeight: number): this;
@@ -110,6 +127,25 @@ declare class FXDialog {
110
127
  * 设置关闭回调
111
128
  */
112
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;
113
149
  /**
114
150
  * 显示弹窗
115
151
  */
@@ -117,12 +153,7 @@ declare class FXDialog {
117
153
  /**
118
154
  * 触发关闭,关闭弹窗, 转发给 DialogManager
119
155
  */
120
- private close;
121
- /**
122
- * 更新弹窗内容
123
- * @param updates 要更新的内容
124
- */
125
- private update;
156
+ protected close(closeType?: FXDialogCloseType): void;
126
157
  /**
127
158
  * 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
128
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,CAAC,CAA0C;IAE5D,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,oBAAoB,CAI1B;IACF,OAAO,CAAC,iBAAiB,CAIvB;IACF;;OAEG;IACH,MAAM,CAAC,KAAK,IAAI,QAAQ;IAIxB,MAAM,CAAC,WAAW,IAAI,QAAQ;IAO9B,MAAM,CAAC,KAAK,IAAI,QAAQ;IAIxB,OAAO,CAAC,MAAM,CAAC,YAAY;IAY3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAQpC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,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AC,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
  * 设置弹窗类型
@@ -37,8 +40,8 @@ class FXDialog {
37
40
  }
38
41
  static createDialog(dialogType, animationType) {
39
42
  const dialog = new this();
40
- dialog.viewConfiguration.type = dialogType;
41
- dialog.viewDefaultAnimation.animationType =
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,45 +75,60 @@ 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
95
  return this;
96
96
  }
97
97
  /**
98
- * 添加背景样式
98
+ * 设置背景样式
99
99
  */
100
100
  backgroundStyle(style) {
101
- this.viewConfiguration.backgroundStyle = Object.assign(Object.assign({}, this.viewConfiguration.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;
102
111
  return this;
103
112
  }
104
113
  /**
105
114
  * 设置容器样式
106
115
  */
107
116
  containerStyle(style) {
108
- this.viewConfiguration.containerStyle = Object.assign(Object.assign({}, this.viewConfiguration.containerStyle), style);
117
+ this._viewConfiguration.containerStyle = Object.assign(Object.assign({}, this._viewConfiguration.containerStyle), style);
109
118
  return this;
110
119
  }
111
120
  /**
112
121
  * 设置内容区域容器样式 除按钮外的内容区域样式
113
122
  */
114
123
  contentsContainerStyle(style) {
115
- this.viewConfiguration.contentsContainerStyle = Object.assign(Object.assign({}, this.viewConfiguration.contentsContainerStyle), style);
124
+ this._viewConfiguration.contentsContainerStyle = Object.assign(Object.assign({}, this._viewConfiguration.contentsContainerStyle), style);
116
125
  return this;
117
126
  }
118
127
  /**
119
128
  * 设置按钮区样式
120
129
  */
121
130
  actionsContainerStyle(style) {
122
- this.viewConfiguration.actionsContainerStyle = Object.assign(Object.assign({}, this.viewConfiguration.actionsContainerStyle), style);
131
+ this._viewConfiguration.actionsContainerStyle = Object.assign(Object.assign({}, this._viewConfiguration.actionsContainerStyle), style);
123
132
  return this;
124
133
  }
125
134
  /**
@@ -127,7 +136,7 @@ class FXDialog {
127
136
  * @param duration 动画时长 ms
128
137
  */
129
138
  showAnimationDuration(duration) {
130
- this.viewDefaultAnimation.showDuration = duration;
139
+ this._viewDefaultAnimation.showDuration = duration;
131
140
  return this;
132
141
  }
133
142
  /**
@@ -135,14 +144,14 @@ class FXDialog {
135
144
  * @param duration 动画时长 ms
136
145
  */
137
146
  closeAnimationDuration(duration) {
138
- this.viewDefaultAnimation.closeDuration = duration;
147
+ this._viewDefaultAnimation.closeDuration = duration;
139
148
  return this;
140
149
  }
141
150
  /**
142
151
  * 设置动画:支持传入内置类型
143
152
  */
144
153
  animationType(animation) {
145
- this.viewDefaultAnimation.animationType = animation;
154
+ this._viewDefaultAnimation.animationType = animation;
146
155
  return this;
147
156
  }
148
157
  /**
@@ -150,22 +159,22 @@ class FXDialog {
150
159
  * @param animator 自定义动画控制器
151
160
  */
152
161
  animator(animator) {
153
- this.viewConfiguration.animator = animator;
162
+ this._viewConfiguration.animator = animator;
154
163
  return this;
155
164
  }
156
165
  /**
157
166
  * 设置弹窗容器最大高度
158
167
  */
159
168
  containerScrollMaxHeight(maxHeight) {
160
- this.viewConfiguration.containerScrollMaxHeight = maxHeight;
169
+ this._viewConfiguration.containerScrollMaxHeight = maxHeight;
161
170
  return this;
162
171
  }
163
172
  /**
164
- * 设置按钮区最小高度
173
+ * 设置弹窗需要滚动时按钮区最小高度
165
174
  * @param minHeight 最小高度
166
175
  */
167
176
  actionsScrollMinHeight(minHeight) {
168
- this.viewConfiguration.actionsScrollMinHeight = minHeight;
177
+ this._viewConfiguration.actionsScrollMinHeight = minHeight;
169
178
  return this;
170
179
  }
171
180
  /**
@@ -173,7 +182,7 @@ class FXDialog {
173
182
  * @param maxHeight 最大高度
174
183
  */
175
184
  actionsScrollMaxHeight(maxHeight) {
176
- this.viewConfiguration.actionsScrollMaxHeight = maxHeight;
185
+ this._viewConfiguration.actionsScrollMaxHeight = maxHeight;
177
186
  return this;
178
187
  }
179
188
  /**
@@ -210,20 +219,88 @@ class FXDialog {
210
219
  this._didClose = callback;
211
220
  return this;
212
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
+ }
213
286
  // region========== 显示方法 ==========
214
287
  /**
215
288
  * 显示弹窗
216
289
  */
217
290
  show(fxViewId) {
218
291
  try {
219
- if (!this.viewConfiguration.animator) {
220
- this.viewConfiguration.animator = this.viewDefaultAnimation;
292
+ if (!this._viewConfiguration.animator) {
293
+ this._viewConfiguration.animator = this._viewDefaultAnimation;
221
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);
222
299
  this._queueItem = FXDialogManager_1.default.getInstance().show({
223
300
  fxViewId: fxViewId,
224
301
  priority: this._priority,
225
302
  enqueue: this._enqueue,
226
- dialogProps: this.viewConfiguration,
303
+ dialogProps: this._viewConfiguration,
227
304
  didShow: this._didShow,
228
305
  didClose: this._didClose,
229
306
  });
@@ -236,6 +313,12 @@ class FXDialog {
236
313
  return {
237
314
  close: this.close.bind(this),
238
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),
239
322
  fxViewId: () => this._fxViewId,
240
323
  };
241
324
  }
@@ -253,32 +336,6 @@ class FXDialog {
253
336
  FXDialogManager_1.default.getInstance().close(this._queueItem, closeType || types_1.FXDialogCloseSystemType.Custom);
254
337
  }
255
338
  }
256
- /**
257
- * 更新弹窗内容
258
- * @param updates 要更新的内容
259
- */
260
- update(updates) {
261
- try {
262
- react_native_fxview_1.logger.log("Dialog update", this._fxViewId);
263
- if (this._queueItem) {
264
- // 通过引用调用DialogView的update方法(只作用于弹窗层)
265
- const dialogViewRef = this._queueItem.dialogViewRef;
266
- react_native_fxview_1.logger.log("[Dialog] update", this._queueItem.dialogViewRef);
267
- if (dialogViewRef && dialogViewRef.current) {
268
- dialogViewRef.current.update(updates);
269
- }
270
- else {
271
- react_native_fxview_1.logger.warn("[Dialog] Cannot update: DialogView ref not available");
272
- }
273
- }
274
- else {
275
- react_native_fxview_1.logger.warn("[Dialog] Cannot update: dialog not shown yet");
276
- }
277
- }
278
- catch (error) {
279
- react_native_fxview_1.logger.error("[Dialog] Failed to update dialog", error);
280
- }
281
- }
282
339
  /**
283
340
  * 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
284
341
  * @param fxViewId 可选,指定要关闭的弹窗的 fxViewId
package/FXDialogView.d.ts CHANGED
@@ -1,13 +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[];
6
+ contents?: FXDialogContent[];
7
+ actions?: FXDialogAction[];
7
8
  backgroundStyle?: ViewStyle;
8
9
  containerStyle?: ViewStyle;
9
10
  contentsContainerStyle?: ViewStyle;
10
11
  actionsContainerStyle?: ViewStyle;
12
+ appendBackground?: React.ReactNode;
13
+ appendContainer?: React.ReactNode;
11
14
  animator?: FXDialogAnimationImpl;
12
15
  closeOnClickBackground?: boolean;
13
16
  actionsScrollMinHeight?: number;
@@ -24,12 +27,16 @@ interface FXDialogViewState {
24
27
  actionsScrollable: boolean;
25
28
  adjustedContentHeight: number;
26
29
  adjustedActionsHeight: number;
27
- displayElements?: FXDialogElement[];
28
- measureElements?: FXDialogElement[];
30
+ displayContents?: FXDialogContent[];
31
+ displayActions?: FXDialogAction[];
32
+ measureContents?: FXDialogContent[];
33
+ measureActions?: FXDialogAction[];
29
34
  containerStyle?: ViewStyle;
30
35
  backgroundStyle?: ViewStyle;
31
36
  contentsContainerStyle?: ViewStyle;
32
37
  actionsContainerStyle?: ViewStyle;
38
+ appendBackground?: React.ReactNode;
39
+ appendContainer?: React.ReactNode;
33
40
  }
34
41
  export declare const FXDialogViewDefaultScrollConfig: {
35
42
  layout: {
@@ -51,7 +58,7 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
51
58
  componentDidMount(): void;
52
59
  componentWillUnmount(): void;
53
60
  shouldComponentUpdate(nextProps: FXDialogViewProps, nextState: FXDialogViewState): boolean;
54
- update(updates: FXDialogUpdateConfiguration): void;
61
+ update(updates: FXDialogUpdateConfig): void;
55
62
  private handleContentLayout;
56
63
  private handleActionsLayout;
57
64
  private checkIfBothMeasured;
@@ -59,14 +66,18 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
59
66
  private calculateScrollState;
60
67
  handleBackdropPress: () => void;
61
68
  handleActionPress: (action: FXDialogAction) => void;
62
- private categorizeElements;
69
+ private categorizeContents;
70
+ private allActions;
63
71
  private renderTitle;
64
72
  private renderMessage;
65
- private renderCustomView;
66
- 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;
67
78
  renderActions: (actions: FXDialogAction[]) => React.JSX.Element;
68
- renderContents: (contentComponents: React.ReactNode[]) => React.JSX.Element;
69
- renderAllArea: (elements: FXDialogElement[]) => React.JSX.Element;
79
+ renderContents: (contents: FXDialogContent[]) => React.JSX.Element;
80
+ renderAllArea: (contents: FXDialogContent[], actions: FXDialogAction[]) => React.JSX.Element;
70
81
  render(): React.JSX.Element;
71
82
  }
72
83
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"FXDialogView.d.ts","sourceRoot":"","sources":["FXDialogView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAML,SAAS,EAKV,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,cAAc,EAEd,eAAe,EAOf,qBAAqB,EAErB,2BAA2B,EAC5B,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