123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /*!
- * (C) Ionic http://ionicframework.com - MIT License
- */
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- const index = require('./index-2e236a04.js');
- const ionicGlobal = require('./ionic-global-6dea5a96.js');
- const overlays = require('./overlays-4c291a05.js');
- const theme = require('./theme-d1c573d2.js');
- require('./index-cc858e97.js');
- require('./index-c8d52405.js');
- require('./helpers-8a48fdea.js');
- require('./hardware-back-button-3d2b1004.js');
- require('./framework-delegate-862d9d00.js');
- require('./gesture-controller-9436f482.js');
- const ionicSelectModalMdCss = ".sc-ion-select-modal-ionic-h{height:100%}ion-list.sc-ion-select-modal-ionic ion-radio.sc-ion-select-modal-ionic::part(container){display:none}ion-list.sc-ion-select-modal-ionic ion-radio.sc-ion-select-modal-ionic::part(label){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-item.sc-ion-select-modal-ionic{--inner-border-width:0}.item-radio-checked.sc-ion-select-modal-ionic{--background:rgba(var(--ion-color-primary-rgb, 0, 84, 233), 0.08);--background-focused:var(--ion-color-primary, #0054e9);--background-focused-opacity:0.2;--background-hover:var(--ion-color-primary, #0054e9);--background-hover-opacity:0.12}.item-checkbox-checked.sc-ion-select-modal-ionic{--background-activated:var(--ion-item-color, var(--ion-text-color, #000));--background-focused:var(--ion-item-color, var(--ion-text-color, #000));--background-hover:var(--ion-item-color, var(--ion-text-color, #000));--color:var(--ion-color-primary, #0054e9)}";
- const IonSelectModalIonicStyle0 = ionicSelectModalMdCss;
- const selectModalIosCss = ".sc-ion-select-modal-ios-h{height:100%}ion-item.sc-ion-select-modal-ios{--inner-padding-end:0}ion-radio.sc-ion-select-modal-ios::after{bottom:0;position:absolute;width:calc(100% - 0.9375rem - 16px);border-width:0px 0px 0.55px 0px;border-style:solid;border-color:var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, var(--ion-background-color-step-250, #c8c7cc))));content:\"\"}ion-radio.sc-ion-select-modal-ios::after{inset-inline-start:calc(0.9375rem + 16px)}";
- const IonSelectModalIosStyle0 = selectModalIosCss;
- const selectModalMdCss = ".sc-ion-select-modal-md-h{height:100%}ion-list.sc-ion-select-modal-md ion-radio.sc-ion-select-modal-md::part(container){display:none}ion-list.sc-ion-select-modal-md ion-radio.sc-ion-select-modal-md::part(label){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-item.sc-ion-select-modal-md{--inner-border-width:0}.item-radio-checked.sc-ion-select-modal-md{--background:rgba(var(--ion-color-primary-rgb, 0, 84, 233), 0.08);--background-focused:var(--ion-color-primary, #0054e9);--background-focused-opacity:0.2;--background-hover:var(--ion-color-primary, #0054e9);--background-hover-opacity:0.12}.item-checkbox-checked.sc-ion-select-modal-md{--background-activated:var(--ion-item-color, var(--ion-text-color, #000));--background-focused:var(--ion-item-color, var(--ion-text-color, #000));--background-hover:var(--ion-item-color, var(--ion-text-color, #000));--color:var(--ion-color-primary, #0054e9)}";
- const IonSelectModalMdStyle0 = selectModalMdCss;
- const SelectModal = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.header = undefined;
- this.multiple = undefined;
- this.options = [];
- }
- closeModal() {
- const modal = this.el.closest('ion-modal');
- if (modal) {
- modal.dismiss();
- }
- }
- findOptionFromEvent(ev) {
- const { options } = this;
- return options.find((o) => o.value === ev.target.value);
- }
- getValues(ev) {
- const { multiple, options } = this;
- if (multiple) {
- // this is a modal with checkboxes (multiple value select)
- // return an array of all the checked values
- return options.filter((o) => o.checked).map((o) => o.value);
- }
- // this is a modal with radio buttons (single value select)
- // return the value that was clicked, otherwise undefined
- const option = ev ? this.findOptionFromEvent(ev) : null;
- return option ? option.value : undefined;
- }
- callOptionHandler(ev) {
- const option = this.findOptionFromEvent(ev);
- const values = this.getValues(ev);
- if (option === null || option === void 0 ? void 0 : option.handler) {
- overlays.safeCall(option.handler, values);
- }
- }
- setChecked(ev) {
- const { multiple } = this;
- const option = this.findOptionFromEvent(ev);
- // this is a modal with checkboxes (multiple value select)
- // we need to set the checked value for this option
- if (multiple && option) {
- option.checked = ev.detail.checked;
- }
- }
- renderRadioOptions() {
- const checked = this.options.filter((o) => o.checked).map((o) => o.value)[0];
- return (index.h("ion-radio-group", { value: checked, onIonChange: (ev) => this.callOptionHandler(ev) }, this.options.map((option) => (index.h("ion-item", { lines: "none", class: Object.assign({
- // TODO FW-4784
- 'item-radio-checked': option.value === checked
- }, theme.getClassMap(option.cssClass)) }, index.h("ion-radio", { value: option.value, disabled: option.disabled, justify: "start", labelPlacement: "end", onClick: () => this.closeModal(), onKeyUp: (ev) => {
- if (ev.key === ' ') {
- /**
- * Selecting a radio option with keyboard navigation,
- * either through the Enter or Space keys, should
- * dismiss the modal.
- */
- this.closeModal();
- }
- } }, option.text))))));
- }
- renderCheckboxOptions() {
- return this.options.map((option) => (index.h("ion-item", { class: Object.assign({
- // TODO FW-4784
- 'item-checkbox-checked': option.checked
- }, theme.getClassMap(option.cssClass)) }, index.h("ion-checkbox", { value: option.value, disabled: option.disabled, checked: option.checked, justify: "start", labelPlacement: "end", onIonChange: (ev) => {
- this.setChecked(ev);
- this.callOptionHandler(ev);
- // TODO FW-4784
- index.forceUpdate(this);
- } }, option.text))));
- }
- render() {
- return (index.h(index.Host, { key: '885198a9f21884e3bfb9bf0af53e0ee3ae37b231', class: ionicGlobal.getIonMode(this) }, index.h("ion-header", { key: 'd8b63726869747ac711e4fda78a50ce46f72970c' }, index.h("ion-toolbar", { key: '9ab2a4c1480dd74eeae38d7b580a2e87fb71270e' }, this.header !== undefined && index.h("ion-title", { key: '87a7034385ef57f55cefdd0371dbb66a64827290' }, this.header), index.h("ion-buttons", { key: '0a35424ea13ca002abc9a43b6138730254f187d0', slot: "end" }, index.h("ion-button", { key: '238bf40b47128d9aa995d14d9ff9ebcae4f79492', onClick: () => this.closeModal() }, "Close")))), index.h("ion-content", { key: '4a256f3381f8cabbc7194337b8ae4aa1c3ab1066' }, index.h("ion-list", { key: 'acd38fc52024632176467ed6a84106a454021544' }, this.multiple === true ? this.renderCheckboxOptions() : this.renderRadioOptions()))));
- }
- get el() { return index.getElement(this); }
- };
- SelectModal.style = {
- ionic: IonSelectModalIonicStyle0,
- ios: IonSelectModalIosStyle0,
- md: IonSelectModalMdStyle0
- };
- exports.ion_select_modal = SelectModal;
|