mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
chore(packages): move the packages to root
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
import { Component, Listen, Method } from '@stencil/core';
|
||||
import { ActionSheetOptions, OverlayController } from '../../index';
|
||||
import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-action-sheet-controller'
|
||||
})
|
||||
export class ActionSheetController implements OverlayController {
|
||||
|
||||
private actionSheets = new Map<number, HTMLIonActionSheetElement>();
|
||||
|
||||
|
||||
@Listen('body:ionActionSheetWillPresent')
|
||||
protected actionSheetWillPresent(ev: any) {
|
||||
this.actionSheets.set(ev.target.overlayId, ev.target);
|
||||
}
|
||||
|
||||
|
||||
@Listen('body:ionActionSheetWillDismiss')
|
||||
@Listen('body:ionActionSheetDidUnload')
|
||||
protected actionSheetWillDismiss(ev: any) {
|
||||
this.actionSheets.delete(ev.target.overlayId);
|
||||
}
|
||||
|
||||
|
||||
@Listen('body:keyup.escape')
|
||||
protected escapeKeyUp() {
|
||||
removeLastOverlay(this.actionSheets);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an action sheet overlay with action sheet options.
|
||||
*/
|
||||
@Method()
|
||||
create(opts?: ActionSheetOptions): Promise<HTMLIonActionSheetElement> {
|
||||
return createOverlay(document.createElement('ion-action-sheet'), opts);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dismiss the open action sheet overlay.
|
||||
*/
|
||||
@Method()
|
||||
dismiss(data?: any, role?: string, actionSheetId = -1) {
|
||||
return dismissOverlay(data, role, this.actionSheets, actionSheetId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the most recently opened action sheet overlay.
|
||||
*/
|
||||
@Method()
|
||||
getTop(): HTMLIonActionSheetElement {
|
||||
return getTopOverlay(this.actionSheets);
|
||||
}
|
||||
}
|
||||
68
core/src/components/action-sheet-controller/readme.md
Normal file
68
core/src/components/action-sheet-controller/readme.md
Normal file
@ -0,0 +1,68 @@
|
||||
# ion-action-sheet-controller
|
||||
|
||||
Action Sheet controllers programmatically control the action sheet component. Action Sheets can be created and dismissed from the action sheet controller. View the [Action Sheet](../../action-sheet/ActionSheet) documentation for a full list of options to pass upon creation.
|
||||
|
||||
```javascript
|
||||
async function presentBasic() {
|
||||
const actionSheetController = document.querySelector('ion-action-sheet-controller');
|
||||
await actionSheetController.componentOnReady();
|
||||
|
||||
const actionSheetElement = await actionSheetController.create({
|
||||
title: "Albums",
|
||||
buttons: [{
|
||||
text: 'Delete',
|
||||
role: 'destructive',
|
||||
icon: 'trash',
|
||||
handler: () => {
|
||||
console.log('Delete clicked');
|
||||
}
|
||||
}, {
|
||||
text: 'Share',
|
||||
icon: 'share',
|
||||
handler: () => {
|
||||
console.log('Share clicked');
|
||||
}
|
||||
}, {
|
||||
text: 'Play (open modal)',
|
||||
icon: 'arrow-dropright-circle',
|
||||
handler: () => {
|
||||
console.log('Play clicked');
|
||||
}
|
||||
}, {
|
||||
text: 'Favorite',
|
||||
icon: 'heart',
|
||||
handler: () => {
|
||||
console.log('Favorite clicked');
|
||||
}
|
||||
}, {
|
||||
text: 'Cancel',
|
||||
icon: 'close',
|
||||
role: 'cancel',
|
||||
handler: () => {
|
||||
console.log('Cancel clicked');
|
||||
}
|
||||
}]
|
||||
});
|
||||
await actionSheetElement.present();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
#### create()
|
||||
|
||||
|
||||
#### dismiss()
|
||||
|
||||
|
||||
#### getTop()
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
||||
Reference in New Issue
Block a user