UNPKG

react-klasha

Version:

This is an reactJS library for implementing klasha payment gateway

1 lines 11.6 kB
import{__awaiter,__generator}from"tslib";import{r as registerInstance,e as createEvent,h,H as Host,i as getElement}from"./index-7a8b7a1c.js";import{b as getIonMode}from"./ionic-global-63a97a32.js";import{a as addEventListener,b as removeEventListener,d as getAriaLabel}from"./helpers-dd7e4b7b.js";import{c as createColorClasses,h as hostContext}from"./theme-ff3fc52f.js";var radioIosCss=':host{--inner-border-radius:50%;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}:host(.radio-disabled){pointer-events:none}.radio-icon{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;contain:layout size style}.radio-icon,.radio-inner{-webkit-box-sizing:border-box;box-sizing:border-box}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}input{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}:host(:focus){outline:none}:host{--color-checked:var(--ion-color-primary, #3880ff);width:15px;height:24px}:host(.ion-color.radio-checked) .radio-inner{border-color:var(--ion-color-base)}.item-radio.item-ios ion-label{margin-left:0}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.item-radio.item-ios ion-label{margin-left:unset;-webkit-margin-start:0;margin-inline-start:0}}.radio-inner{width:33%;height:50%}:host(.radio-checked) .radio-inner{-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)}:host(.radio-disabled){opacity:0.3}:host(.ion-focused) .radio-icon::after{border-radius:var(--inner-border-radius);left:-9px;top:-8px;display:block;position:absolute;width:36px;height:36px;background:var(--ion-color-primary-tint, #4c8dff);content:"";opacity:0.2}:host-context([dir=rtl]):host(.ion-focused) .radio-icon::after,:host-context([dir=rtl]).ion-focused .radio-icon::after{left:unset;right:unset;right:-9px}:host(.in-item){margin-left:10px;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){:host(.in-item){margin-left:unset;margin-right:unset;-webkit-margin-start:10px;margin-inline-start:10px;-webkit-margin-end:11px;margin-inline-end:11px}}:host(.in-item[slot=start]){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){:host(.in-item[slot=start]){margin-left:unset;margin-right:unset;-webkit-margin-start:3px;margin-inline-start:3px;-webkit-margin-end:21px;margin-inline-end:21px}}';var radioMdCss=':host{--inner-border-radius:50%;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}:host(.radio-disabled){pointer-events:none}.radio-icon{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;contain:layout size style}.radio-icon,.radio-inner{-webkit-box-sizing:border-box;box-sizing:border-box}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}input{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}:host(:focus){outline:none}:host{--color:var(--ion-color-step-400, #999999);--color-checked:var(--ion-color-primary, #3880ff);--border-width:2px;--border-style:solid;--border-radius:50%;width:20px;height:20px}:host(.ion-color) .radio-inner{background:var(--ion-color-base)}:host(.ion-color.radio-checked) .radio-icon{border-color:var(--ion-color-base)}.radio-icon{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;border-radius:var(--border-radius);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--color)}.radio-inner{border-radius:var(--inner-border-radius);width:calc(50% + var(--border-width));height:calc(50% + var(--border-width));-webkit-transform:scale3d(0, 0, 0);transform:scale3d(0, 0, 0);-webkit-transition:-webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:transform 280ms cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);background:var(--color-checked)}:host(.radio-checked) .radio-icon{border-color:var(--color-checked)}:host(.radio-checked) .radio-inner{-webkit-transform:scale3d(1, 1, 1);transform:scale3d(1, 1, 1)}:host(.radio-disabled){opacity:0.3}:host(.ion-focused) .radio-icon::after{border-radius:var(--inner-border-radius);left:-12px;top:-12px;display:block;position:absolute;width:36px;height:36px;background:var(--ion-color-primary-tint, #4c8dff);content:"";opacity:0.2}:host-context([dir=rtl]):host(.ion-focused) .radio-icon::after,:host-context([dir=rtl]).ion-focused .radio-icon::after{left:unset;right:unset;right:-12px}:host(.in-item){margin-left:0;margin-right:0;margin-top:9px;margin-bottom:9px;display:block;position:static}:host(.in-item[slot=start]){margin-left:4px;margin-right:36px;margin-top:11px;margin-bottom:10px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){:host(.in-item[slot=start]){margin-left:unset;margin-right:unset;-webkit-margin-start:4px;margin-inline-start:4px;-webkit-margin-end:36px;margin-inline-end:36px}}';var Radio=function(){function e(e){var t=this;registerInstance(this,e);this.ionStyle=createEvent(this,"ionStyle",7);this.ionFocus=createEvent(this,"ionFocus",7);this.ionBlur=createEvent(this,"ionBlur",7);this.inputId="ion-rb-"+radioButtonIds++;this.radioGroup=null;this.checked=false;this.buttonTabindex=-1;this.name=this.inputId;this.disabled=false;this.updateState=function(){if(t.radioGroup){t.checked=t.radioGroup.value===t.value}};this.onFocus=function(){t.ionFocus.emit()};this.onBlur=function(){t.ionBlur.emit()}}e.prototype.setFocus=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){e.stopPropagation();e.preventDefault();this.el.focus();return[2]}))}))};e.prototype.setButtonTabindex=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.buttonTabindex=e;return[2]}))}))};e.prototype.connectedCallback=function(){if(this.value===undefined){this.value=this.inputId}var e=this.radioGroup=this.el.closest("ion-radio-group");if(e){this.updateState();addEventListener(e,"ionChange",this.updateState)}};e.prototype.disconnectedCallback=function(){var e=this.radioGroup;if(e){removeEventListener(e,"ionChange",this.updateState);this.radioGroup=null}};e.prototype.componentWillLoad=function(){this.emitStyle()};e.prototype.emitStyle=function(){this.ionStyle.emit({"radio-checked":this.checked,"interactive-disabled":this.disabled})};e.prototype.render=function(){var e;var t=this,i=t.inputId,r=t.disabled,o=t.checked,n=t.color,a=t.el,s=t.buttonTabindex;var l=getIonMode(this);var d=getAriaLabel(a,i),c=d.label,u=d.labelId,p=d.labelText;return h(Host,{"aria-checked":""+o,"aria-hidden":r?"true":null,"aria-labelledby":c?u:null,role:"radio",tabindex:s,onFocus:this.onFocus,onBlur:this.onBlur,class:createColorClasses(n,(e={},e[l]=true,e["in-item"]=hostContext("ion-item",a),e["interactive"]=true,e["radio-checked"]=o,e["radio-disabled"]=r,e))},h("div",{class:"radio-icon",part:"container"},h("div",{class:"radio-inner",part:"mark"}),h("div",{class:"radio-ripple"})),h("label",{htmlFor:i},p),h("input",{type:"radio",checked:o,disabled:r,tabindex:"-1",id:i}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{color:["emitStyle"],checked:["emitStyle"],disabled:["emitStyle"]}},enumerable:false,configurable:true});return e}();var radioButtonIds=0;Radio.style={ios:radioIosCss,md:radioMdCss};var RadioGroup=function(){function e(e){var t=this;registerInstance(this,e);this.ionChange=createEvent(this,"ionChange",7);this.inputId="ion-rg-"+radioGroupIds++;this.labelId=this.inputId+"-lbl";this.allowEmptySelection=false;this.name=this.inputId;this.setRadioTabindex=function(e){var i=t.getRadios();var r=i.find((function(e){return!e.disabled}));var o=i.find((function(t){return t.value===e&&!t.disabled}));if(!r&&!o){return}var n=o||r;for(var a=0,s=i;a<s.length;a++){var l=s[a];var d=l===n?0:-1;l.setButtonTabindex(d)}};this.onClick=function(e){e.preventDefault();var i=e.target&&e.target.closest("ion-radio");if(i){var r=t.value;var o=i.value;if(o!==r){t.value=o}else if(t.allowEmptySelection){t.value=undefined}}}}e.prototype.valueChanged=function(e){this.setRadioTabindex(e);this.ionChange.emit({value:e})};e.prototype.componentDidLoad=function(){this.setRadioTabindex(this.value)};e.prototype.connectedCallback=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){e=this.el.querySelector("ion-list-header")||this.el.querySelector("ion-item-divider");if(e){t=this.label=e.querySelector("ion-label");if(t){this.labelId=t.id=this.name+"-lbl"}}return[2]}))}))};e.prototype.getRadios=function(){return Array.from(this.el.querySelectorAll("ion-radio"))};e.prototype.onKeydown=function(e){var t=!!this.el.closest("ion-select-popover");if(e.target&&!this.el.contains(e.target)){return}var i=this.getRadios().filter((function(e){return!e.disabled}));if(e.target&&i.includes(e.target)){var r=i.findIndex((function(t){return t===e.target}));var o=i[r];var n=void 0;if(["ArrowDown","ArrowRight"].includes(e.code)){n=r===i.length-1?i[0]:i[r+1]}if(["ArrowUp","ArrowLeft"].includes(e.code)){n=r===0?i[i.length-1]:i[r-1]}if(n&&i.includes(n)){n.setFocus(e);if(!t){this.value=n.value}}if(["Space"].includes(e.code)){this.value=this.allowEmptySelection&&this.value!==undefined?undefined:o.value;e.preventDefault()}}};e.prototype.render=function(){var e=this,t=e.label,i=e.labelId;var r=getIonMode(this);return h(Host,{role:"radiogroup","aria-labelledby":t?i:null,onClick:this.onClick,class:r})};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{value:["valueChanged"]}},enumerable:false,configurable:true});return e}();var radioGroupIds=0;export{Radio as ion_radio,RadioGroup as ion_radio_group};