UNPKG

@ionic/core

Version:
4 lines 5.95 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as registerInstance,h,i as forceUpdate,e as Host,f as getElement}from"./index-527b9e34.js";import{b as getIonMode}from"./ionic-global-ca86cf32.js";import{s as safeCall}from"./overlays-41a5d51b.js";import{g as getClassMap}from"./theme-01f3f29c.js";import"./index-a5d50daf.js";import"./helpers-78efeec3.js";import"./hardware-back-button-864101a3.js";import"./framework-delegate-2eea1763.js";import"./gesture-controller-314a54f6.js";import"./index-738d7504.js";var 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)}";var IonSelectModalIonicStyle0=ionicSelectModalMdCss;var 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)}';var IonSelectModalIosStyle0=selectModalIosCss;var 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)}";var IonSelectModalMdStyle0=selectModalMdCss;var SelectModal=function(){function o(o){registerInstance(this,o);this.header=undefined;this.multiple=undefined;this.options=[]}o.prototype.closeModal=function(){var o=this.el.closest("ion-modal");if(o){o.dismiss()}};o.prototype.findOptionFromEvent=function(o){var e=this.options;return e.find((function(e){return e.value===o.target.value}))};o.prototype.getValues=function(o){var e=this,i=e.multiple,n=e.options;if(i){return n.filter((function(o){return o.checked})).map((function(o){return o.value}))}var t=o?this.findOptionFromEvent(o):null;return t?t.value:undefined};o.prototype.callOptionHandler=function(o){var e=this.findOptionFromEvent(o);var i=this.getValues(o);if(e===null||e===void 0?void 0:e.handler){safeCall(e.handler,i)}};o.prototype.setChecked=function(o){var e=this.multiple;var i=this.findOptionFromEvent(o);if(e&&i){i.checked=o.detail.checked}};o.prototype.renderRadioOptions=function(){var o=this;var e=this.options.filter((function(o){return o.checked})).map((function(o){return o.value}))[0];return h("ion-radio-group",{value:e,onIonChange:function(e){return o.callOptionHandler(e)}},this.options.map((function(i){return h("ion-item",{lines:"none",class:Object.assign({"item-radio-checked":i.value===e},getClassMap(i.cssClass))},h("ion-radio",{value:i.value,disabled:i.disabled,justify:"start",labelPlacement:"end",onClick:function(){return o.closeModal()},onKeyUp:function(e){if(e.key===" "){o.closeModal()}}},i.text))})))};o.prototype.renderCheckboxOptions=function(){var o=this;return this.options.map((function(e){return h("ion-item",{class:Object.assign({"item-checkbox-checked":e.checked},getClassMap(e.cssClass))},h("ion-checkbox",{value:e.value,disabled:e.disabled,checked:e.checked,justify:"start",labelPlacement:"end",onIonChange:function(e){o.setChecked(e);o.callOptionHandler(e);forceUpdate(o)}},e.text))}))};o.prototype.render=function(){var o=this;return h(Host,{key:"885198a9f21884e3bfb9bf0af53e0ee3ae37b231",class:getIonMode(this)},h("ion-header",{key:"d8b63726869747ac711e4fda78a50ce46f72970c"},h("ion-toolbar",{key:"9ab2a4c1480dd74eeae38d7b580a2e87fb71270e"},this.header!==undefined&&h("ion-title",{key:"87a7034385ef57f55cefdd0371dbb66a64827290"},this.header),h("ion-buttons",{key:"0a35424ea13ca002abc9a43b6138730254f187d0",slot:"end"},h("ion-button",{key:"238bf40b47128d9aa995d14d9ff9ebcae4f79492",onClick:function(){return o.closeModal()}},"Close")))),h("ion-content",{key:"4a256f3381f8cabbc7194337b8ae4aa1c3ab1066"},h("ion-list",{key:"acd38fc52024632176467ed6a84106a454021544"},this.multiple===true?this.renderCheckboxOptions():this.renderRadioOptions())))};Object.defineProperty(o.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return o}();SelectModal.style={ionic:IonSelectModalIonicStyle0,ios:IonSelectModalIosStyle0,md:IonSelectModalMdStyle0};export{SelectModal as ion_select_modal};