-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
Copy pathcontrollers.ts
95 lines (87 loc) · 2.72 KB
/
controllers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import {
modalController as modalCtrl,
popoverController as popoverCtrl,
alertController as alertCtrl,
actionSheetController as actionSheetCtrl,
loadingController as loadingCtrl,
pickerController as pickerCtrl,
toastController as toastCtrl,
} from "@ionic/core/components";
import { defineCustomElement as defineIonActionSheetCustomElement } from "@ionic/core/components/ion-action-sheet.js";
import { defineCustomElement as defineIonAlertCustomElement } from "@ionic/core/components/ion-alert.js";
import { defineCustomElement as defineIonLoadingCustomElement } from "@ionic/core/components/ion-loading.js";
import { defineCustomElement as defineIonModalCustomElement } from "@ionic/core/components/ion-modal.js";
import { defineCustomElement as defineIonPickerCustomElement } from "@ionic/core/components/ion-picker-legacy.js";
import { defineCustomElement as defineIonPopoverCustomElement } from "@ionic/core/components/ion-popover.js";
import { defineCustomElement as defineIonToastCustomElement } from "@ionic/core/components/ion-toast.js";
import { VueDelegate } from "./framework-delegate";
// TODO(FW-2969): types
/**
* Wrap the controllers export from @ionic/core
* register the underlying Web Component and
* (optionally) provide a framework delegate.
*/
const createController: {
<T>(
defineCustomElement: () => void,
oldController: T,
useDelegate?: boolean
): T;
} = (
defineCustomElement: () => void,
oldController: any,
useDelegate = false
) => {
const delegate = useDelegate ? VueDelegate() : undefined;
const oldCreate = oldController.create.bind(oldController);
oldController.create = (options: any) => {
defineCustomElement();
return oldCreate({
...options,
delegate,
});
};
return oldController;
};
const modalController = /*@__PURE__*/ createController(
defineIonModalCustomElement,
modalCtrl,
true
);
const popoverController = /*@__PURE__*/ createController(
defineIonPopoverCustomElement,
popoverCtrl,
true
);
const alertController = /*@__PURE__*/ createController(
defineIonAlertCustomElement,
alertCtrl
);
const actionSheetController = /*@__PURE__*/ createController(
defineIonActionSheetCustomElement,
actionSheetCtrl
);
const loadingController = /*@__PURE__*/ createController(
defineIonLoadingCustomElement,
loadingCtrl
);
/**
* @deprecated Use the inline ion-picker component instead.
*/
const pickerController = /*@__PURE__*/ createController(
defineIonPickerCustomElement,
pickerCtrl
);
const toastController = /*@__PURE__*/ createController(
defineIonToastCustomElement,
toastCtrl
);
export {
modalController,
popoverController,
alertController,
actionSheetController,
loadingController,
pickerController,
toastController,
};