Files
ionic-framework/packages/vue/src/controllers.ts
Liam DeBeasi cd5c099dd3 feat(picker): add inline picker (#28689)
Issue number: resolves #24905, resolves #26840, resolves #15710

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

The current picker is only displayed as an overlay which makes it
impossible to use inline with the rest of the application. Additionally,
there are several bugs and missing features. For example, it is
impossible to know when the value of the picker column has changed using
public APIs. This is valuable for updating other columns in response to
that data.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Introduces `ion-picker` as an inline wheel picker component. The
overlay picker is still available using `ion-picker-legacy`.
- The implementation of this component resolves linked bugs. It also
resolves linked features by exposing an `ionChange` event for developers
to listen for.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev-build: `7.5.8-dev.11702398696.1ab62ea9`

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Shawn Taylor <shawn@ionic.io>
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
Co-authored-by: Sean Perkins <13732623+sean-perkins@users.noreply.github.com>
Co-authored-by: Brandy Carney <brandyscarney@users.noreply.github.com>
2023-12-13 13:03:58 -05:00

96 lines
2.7 KiB
TypeScript

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,
};