UNPKG

@ionic/core

Version:
1 lines 7.02 kB
const e=window.Ionic.h;import{c as t,d as i}from"./chunk-7c632336.js";import{d as o}from"./chunk-6d7d2f8c.js";class a{constructor(){this.inputId=`ion-rb-${l++}`,this.name=this.inputId,this.disabled=!1,this.checked=!1,this.onFocus=(()=>{this.ionFocus.emit()}),this.onBlur=(()=>{this.ionBlur.emit()})}colorChanged(){this.emitStyle()}checkedChanged(e){e&&this.ionSelect.emit({checked:!0,value:this.value}),this.emitStyle()}disabledChanged(){this.emitStyle()}componentWillLoad(){void 0===this.value&&(this.value=this.inputId),this.emitStyle()}componentDidLoad(){this.ionRadioDidLoad.emit()}componentDidUnload(){this.ionRadioDidUnload.emit()}onClick(){this.checked?this.ionDeselect.emit():this.checked=!0}emitStyle(){this.ionStyle.emit({"radio-checked":this.checked,"interactive-disabled":this.disabled})}hostData(){const{inputId:e,disabled:a,checked:l,color:n,el:d}=this,s=e+"-lbl",c=o(d);return c&&(c.id=s),{role:"radio","aria-disabled":a?"true":null,"aria-checked":`${l}`,"aria-labelledby":s,class:Object.assign({},t(n),{"in-item":i("ion-item",d),interactive:!0,"radio-checked":l,"radio-disabled":a})}}render(){return[e("div",{class:"radio-icon"},e("div",{class:"radio-inner"})),e("button",{type:"button",onFocus:this.onFocus,onBlur:this.onBlur,disabled:this.disabled})]}static get is(){return"ion-radio"}static get encapsulation(){return"shadow"}static get properties(){return{checked:{type:Boolean,attr:"checked",mutable:!0,watchCallbacks:["checkedChanged"]},color:{type:String,attr:"color",watchCallbacks:["colorChanged"]},disabled:{type:Boolean,attr:"disabled",watchCallbacks:["disabledChanged"]},el:{elementRef:!0},mode:{type:String,attr:"mode"},name:{type:String,attr:"name"},value:{type:"Any",attr:"value",mutable:!0}}}static get events(){return[{name:"ionRadioDidLoad",method:"ionRadioDidLoad",bubbles:!0,cancelable:!0,composed:!0},{name:"ionRadioDidUnload",method:"ionRadioDidUnload",bubbles:!0,cancelable:!0,composed:!0},{name:"ionStyle",method:"ionStyle",bubbles:!0,cancelable:!0,composed:!0},{name:"ionSelect",method:"ionSelect",bubbles:!0,cancelable:!0,composed:!0},{name:"ionDeselect",method:"ionDeselect",bubbles:!0,cancelable:!0,composed:!0},{name:"ionFocus",method:"ionFocus",bubbles:!0,cancelable:!0,composed:!0},{name:"ionBlur",method:"ionBlur",bubbles:!0,cancelable:!0,composed:!0}]}static get listeners(){return[{name:"click",method:"onClick"}]}static get style(){return".sc-ion-radio-ios-h{display:inline-block;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:2}.radio-disabled.sc-ion-radio-ios-h{pointer-events:none}.radio-icon.sc-ion-radio-ios{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;contain:layout size style}.radio-icon.sc-ion-radio-ios, button.sc-ion-radio-ios{width:100%;height:100%}button.sc-ion-radio-ios{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;border:0;background:transparent;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none}[dir=rtl].sc-ion-radio-ios-h button.sc-ion-radio-ios, [dir=rtl] .sc-ion-radio-ios-h button.sc-ion-radio-ios{right:0}button.sc-ion-radio-ios::-moz-focus-inner{border:0}.radio-icon.sc-ion-radio-ios, .radio-inner.sc-ion-radio-ios{-webkit-box-sizing:border-box;box-sizing:border-box}.sc-ion-radio-ios-h{--color-checked:var(--ion-color-primary,#3880ff);width:15px;height:24px}.ion-color.radio-checked.sc-ion-radio-ios-h .radio-inner.sc-ion-radio-ios{border-color:var(--ion-color-base)}.item-radio.item-ios.sc-ion-radio-ios ion-label.sc-ion-radio-ios{margin-left:0}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.item-radio.item-ios.sc-ion-radio-ios ion-label.sc-ion-radio-ios{margin-left:unset;-webkit-margin-start:0;margin-inline-start:0}}.radio-inner.sc-ion-radio-ios{width:33%;height:50%}.radio-checked.sc-ion-radio-ios-h .radio-inner.sc-ion-radio-ios{-webkit-transform:rotate(45deg);transform:rotate(45deg);border-width:2px;border-top-width:0;border-left-width:0;border-style:solid;border-color:var(--color-checked)}.radio-disabled.sc-ion-radio-ios-h{opacity:.3}.ion-focused.sc-ion-radio-ios-h .radio-icon.sc-ion-radio-ios:after{border-radius:50%;left:-9px;top:-8px;display:block;position:absolute;width:36px;height:36px;background:var(--ion-color-primary-tint,#4c8dff);content:\"\";opacity:.2}[dir=rtl].ion-focused.sc-ion-radio-ios-h .radio-icon.sc-ion-radio-ios:after{right:-9px}.in-item.sc-ion-radio-ios-h{margin-left:8px;margin-right:11px;margin-top:8px;margin-bottom:8px;display:block;position:static}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.in-item.sc-ion-radio-ios-h{margin-left:unset;margin-right:unset;-webkit-margin-start:8px;margin-inline-start:8px;-webkit-margin-end:11px;margin-inline-end:11px}}.in-item[slot=start].sc-ion-radio-ios-h{margin-left:3px;margin-right:21px;margin-top:8px;margin-bottom:8px}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.in-item[slot=start].sc-ion-radio-ios-h{margin-left:unset;margin-right:unset;-webkit-margin-start:3px;margin-inline-start:3px;-webkit-margin-end:21px;margin-inline-end:21px}}"}static get styleMode(){return"ios"}}let l=0;class n{constructor(){this.inputId=`ion-rg-${d++}`,this.labelId=`${this.inputId}-lbl`,this.radios=[],this.allowEmptySelection=!1,this.name=this.inputId}valueChanged(e){this.updateRadios(),this.ionChange.emit({value:e})}onRadioDidLoad(e){const t=e.target;t.name=this.name,this.radios.push(t),null==this.value&&t.checked?this.value=t.value:this.updateRadios()}onRadioDidUnload(e){const t=this.radios.indexOf(e.target);t>-1&&this.radios.splice(t,1)}onRadioSelect(e){const t=e.target;t&&(this.value=t.value)}onRadioDeselect(e){if(this.allowEmptySelection){const t=e.target;t&&(t.checked=!1,this.value=void 0)}}componentDidLoad(){let e=this.el.querySelector("ion-list-header");if(e||(e=this.el.querySelector("ion-item-divider")),e){const t=e.querySelector("ion-label");t&&(this.labelId=t.id=this.name+"-lbl")}this.updateRadios()}updateRadios(){const e=this.value;let t=!1;for(const i of this.radios)t||i.value!==e?i.checked=!1:(t=!0,i.checked=!0)}hostData(){return{role:"radiogroup","aria-labelledby":this.labelId}}static get is(){return"ion-radio-group"}static get properties(){return{allowEmptySelection:{type:Boolean,attr:"allow-empty-selection"},el:{elementRef:!0},name:{type:String,attr:"name"},value:{type:"Any",attr:"value",mutable:!0,watchCallbacks:["valueChanged"]}}}static get events(){return[{name:"ionChange",method:"ionChange",bubbles:!0,cancelable:!0,composed:!0}]}static get listeners(){return[{name:"ionRadioDidLoad",method:"onRadioDidLoad"},{name:"ionRadioDidUnload",method:"onRadioDidUnload"},{name:"ionSelect",method:"onRadioSelect"},{name:"ionDeselect",method:"onRadioDeselect"}]}}let d=0;export{a as IonRadio,n as IonRadioGroup};