Files
Hackathon_2025/ready/public/assets/use-key-composition-DhHSCGmF.js
2025-09-14 19:34:53 +02:00

2 lines
13 KiB
JavaScript

import{g as w,r as g,al as oe,f as le,aD as te,w as R,o as G,d as T,a as s,ac as re,a6 as ne,q as ue,e as ae,ae as ie,af as se,h as a,a3 as F,Q as K,aE as de,b as $,T as fe,$ as ce}from"./index-CoQ-x5A8.js";import{u as ve}from"./use-id-G4Q8n9zP.js";import{u as pe,a as me}from"./use-dark-dqtTUvyg.js";import{a as ge,c as be}from"./focus-manager-BJWzFvJg.js";const N=/^on[A-Z]/;function he(){const{attrs:e,vnode:o}=w(),t={listeners:g({}),attributes:g({})};function r(){const f={},i={};for(const n in e)n!=="class"&&n!=="style"&&N.test(n)===!1&&(f[n]=e[n]);for(const n in o.props)N.test(n)===!0&&(i[n]=o.props[n]);t.attributes.value=f,t.listeners.value=i}return oe(r),r(),t}function Ce({validate:e,resetValidation:o,requiresQForm:t}){const r=le(te,!1);if(r!==!1){const{props:f,proxy:i}=w();Object.assign(i,{validate:e,resetValidation:o}),R(()=>f.disable,n=>{n===!0?(typeof o=="function"&&o(),r.unbindComponent(i)):r.bindComponent(i)}),G(()=>{f.disable!==!0&&r.bindComponent(i)}),T(()=>{f.disable!==!0&&r.unbindComponent(i)})}else t===!0&&console.error("Parent QForm not found on useFormChild()!")}const Q=/^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/,Z=/^#[0-9a-fA-F]{4}([0-9a-fA-F]{4})?$/,J=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,E=/^rgb\(((0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),){2}(0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5])\)$/,I=/^rgba\(((0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),){2}(0|[1-9][\d]?|1[\d]{0,2}|2[\d]?|2[0-4][\d]|25[0-5]),(0|0\.[0-9]+[1-9]|0\.[1-9]+|1)\)$/,M={date:e=>/^-?[\d]+\/[0-1]\d\/[0-3]\d$/.test(e),time:e=>/^([0-1]?\d|2[0-3]):[0-5]\d$/.test(e),fulltime:e=>/^([0-1]?\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(e),timeOrFulltime:e=>/^([0-1]?\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/.test(e),email:e=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e),hexColor:e=>Q.test(e),hexaColor:e=>Z.test(e),hexOrHexaColor:e=>J.test(e),rgbColor:e=>E.test(e),rgbaColor:e=>I.test(e),rgbOrRgbaColor:e=>E.test(e)||I.test(e),hexOrRgbColor:e=>Q.test(e)||E.test(e),hexaOrRgbaColor:e=>Z.test(e)||I.test(e),anyColor:e=>J.test(e)||E.test(e)||I.test(e)},qe=[!0,!1,"ondemand"],ye={modelValue:{},error:{type:Boolean,default:null},errorMessage:String,noErrorIcon:Boolean,rules:Array,reactiveRules:Boolean,lazyRules:{type:[Boolean,String],default:!1,validator:e=>qe.includes(e)}};function _e(e,o){const{props:t,proxy:r}=w(),f=g(!1),i=g(null),n=g(!1);Ce({validate:x,resetValidation:_});let c=0,b;const V=s(()=>t.rules!==void 0&&t.rules!==null&&t.rules.length!==0),m=s(()=>t.disable!==!0&&V.value===!0&&o.value===!1),y=s(()=>t.error===!0||f.value===!0),P=s(()=>typeof t.errorMessage=="string"&&t.errorMessage.length!==0?t.errorMessage:i.value);R(()=>t.modelValue,()=>{n.value=!0,m.value===!0&&t.lazyRules===!1&&C()});function A(){t.lazyRules!=="ondemand"&&m.value===!0&&n.value===!0&&C()}R(()=>t.reactiveRules,h=>{h===!0?b===void 0&&(b=R(()=>t.rules,A,{immediate:!0,deep:!0})):b!==void 0&&(b(),b=void 0)},{immediate:!0}),R(()=>t.lazyRules,A),R(e,h=>{h===!0?n.value=!0:m.value===!0&&t.lazyRules!=="ondemand"&&C()});function _(){c++,o.value=!1,n.value=!1,f.value=!1,i.value=null,C.cancel()}function x(h=t.modelValue){if(t.disable===!0||V.value===!1)return!0;const S=++c,O=o.value!==!0?()=>{n.value=!0}:()=>{},q=(d,v)=>{d===!0&&O(),f.value=d,i.value=v||null,o.value=!1},B=[];for(let d=0;d<t.rules.length;d++){const v=t.rules[d];let p;if(typeof v=="function"?p=v(h,M):typeof v=="string"&&M[v]!==void 0&&(p=M[v](h)),p===!1||typeof p=="string")return q(!0,p),!1;p!==!0&&p!==void 0&&B.push(p)}return B.length===0?(q(!1),!0):(o.value=!0,Promise.all(B).then(d=>{if(d===void 0||Array.isArray(d)===!1||d.length===0)return S===c&&q(!1),!0;const v=d.find(p=>p===!1||typeof p=="string");return S===c&&q(v!==void 0,v),v===void 0},d=>(S===c&&(console.error(d),q(!0)),!1)))}const C=re(x,0);return T(()=>{b?.(),C.cancel()}),Object.assign(r,{resetValidation:_,validate:x}),ne(r,"hasError",()=>y.value),{isDirtyModel:n,hasRules:V,hasError:y,errorMessage:P,validate:x,resetValidation:_}}function xe(e){return e!=null&&(""+e).length!==0}const Se={...pe,...ye,label:String,stackLabel:Boolean,hint:String,hideHint:Boolean,prefix:String,suffix:String,labelColor:String,color:String,bgColor:String,filled:Boolean,outlined:Boolean,borderless:Boolean,standout:[Boolean,String],square:Boolean,loading:Boolean,labelSlot:Boolean,bottomSlots:Boolean,hideBottomSpace:Boolean,rounded:Boolean,dense:Boolean,itemAligned:Boolean,counter:Boolean,clearable:Boolean,clearIcon:String,disable:Boolean,readonly:Boolean,autofocus:Boolean,for:String},Ee={...Se,maxlength:[Number,String]},Ie=["update:modelValue","clear","focus","blur"];function Pe({requiredForAttr:e=!0,tagProp:o,changeEvent:t=!1}={}){const{props:r,proxy:f}=w(),i=me(r,f.$q),n=ve({required:e,getValue:()=>r.for});return{requiredForAttr:e,changeEvent:t,tag:o===!0?s(()=>r.tag):{value:"label"},isDark:i,editable:s(()=>r.disable!==!0&&r.readonly!==!0),innerLoading:g(!1),focused:g(!1),hasPopupOpen:!1,splitAttrs:he(),targetUid:n,rootRef:g(null),targetRef:g(null),controlRef:g(null)}}function Oe(e){const{props:o,emit:t,slots:r,attrs:f,proxy:i}=w(),{$q:n}=i;let c=null;e.hasValue===void 0&&(e.hasValue=s(()=>xe(o.modelValue))),e.emitValue===void 0&&(e.emitValue=l=>{t("update:modelValue",l)}),e.controlEvents===void 0&&(e.controlEvents={onFocusin:z,onFocusout:j}),Object.assign(e,{clearValue:D,onControlFocusin:z,onControlFocusout:j,focus:v}),e.computedCounter===void 0&&(e.computedCounter=s(()=>{if(o.counter!==!1){const l=typeof o.modelValue=="string"||typeof o.modelValue=="number"?(""+o.modelValue).length:Array.isArray(o.modelValue)===!0?o.modelValue.length:0,u=o.maxlength!==void 0?o.maxlength:o.maxValues;return l+(u!==void 0?" / "+u:"")}}));const{isDirtyModel:b,hasRules:V,hasError:m,errorMessage:y,resetValidation:P}=_e(e.focused,e.innerLoading),A=e.floatingLabel!==void 0?s(()=>o.stackLabel===!0||e.focused.value===!0||e.floatingLabel.value===!0):s(()=>o.stackLabel===!0||e.focused.value===!0||e.hasValue.value===!0),_=s(()=>o.bottomSlots===!0||o.hint!==void 0||V.value===!0||o.counter===!0||o.error!==null),x=s(()=>o.filled===!0?"filled":o.outlined===!0?"outlined":o.borderless===!0?"borderless":o.standout?"standout":"standard"),C=s(()=>`q-field row no-wrap items-start q-field--${x.value}`+(e.fieldClass!==void 0?` ${e.fieldClass.value}`:"")+(o.rounded===!0?" q-field--rounded":"")+(o.square===!0?" q-field--square":"")+(A.value===!0?" q-field--float":"")+(S.value===!0?" q-field--labeled":"")+(o.dense===!0?" q-field--dense":"")+(o.itemAligned===!0?" q-field--item-aligned q-item-type":"")+(e.isDark.value===!0?" q-field--dark":"")+(e.getControl===void 0?" q-field--auto-height":"")+(e.focused.value===!0?" q-field--focused":"")+(m.value===!0?" q-field--error":"")+(m.value===!0||e.focused.value===!0?" q-field--highlighted":"")+(o.hideBottomSpace!==!0&&_.value===!0?" q-field--with-bottom":"")+(o.disable===!0?" q-field--disabled":o.readonly===!0?" q-field--readonly":"")),h=s(()=>"q-field__control relative-position row no-wrap"+(o.bgColor!==void 0?` bg-${o.bgColor}`:"")+(m.value===!0?" text-negative":typeof o.standout=="string"&&o.standout.length!==0&&e.focused.value===!0?` ${o.standout}`:o.color!==void 0?` text-${o.color}`:"")),S=s(()=>o.labelSlot===!0||o.label!==void 0),O=s(()=>"q-field__label no-pointer-events absolute ellipsis"+(o.labelColor!==void 0&&m.value!==!0?` text-${o.labelColor}`:"")),q=s(()=>({id:e.targetUid.value,editable:e.editable.value,focused:e.focused.value,floatingLabel:A.value,modelValue:o.modelValue,emitValue:e.emitValue})),B=s(()=>{const l={};return e.targetUid.value&&(l.for=e.targetUid.value),o.disable===!0&&(l["aria-disabled"]="true"),l});function d(){const l=document.activeElement;let u=e.targetRef?.value;u&&(l===null||l.id!==e.targetUid.value)&&(u.hasAttribute("tabindex")===!0||(u=u.querySelector("[tabindex]")),u!==l&&u?.focus({preventScroll:!0}))}function v(){ge(d)}function p(){be(d);const l=document.activeElement;l!==null&&e.rootRef.value.contains(l)&&l.blur()}function z(l){c!==null&&(clearTimeout(c),c=null),e.editable.value===!0&&e.focused.value===!1&&(e.focused.value=!0,t("focus",l))}function j(l,u){c!==null&&clearTimeout(c),c=setTimeout(()=>{c=null,!(document.hasFocus()===!0&&(e.hasPopupOpen===!0||e.controlRef===void 0||e.controlRef.value===null||e.controlRef.value.contains(document.activeElement)!==!1))&&(e.focused.value===!0&&(e.focused.value=!1,t("blur",l)),u?.())})}function D(l){ue(l),n.platform.is.mobile!==!0?(e.targetRef?.value||e.rootRef.value).focus():e.rootRef.value.contains(document.activeElement)===!0&&document.activeElement.blur(),o.type==="file"&&(e.inputRef.value.value=null),t("update:modelValue",null),e.changeEvent===!0&&t("change",null),t("clear",o.modelValue),ae(()=>{const u=b.value;P(),b.value=u})}function W(l){[13,32].includes(l.keyCode)&&D(l)}function X(){const l=[];return r.prepend!==void 0&&l.push(a("div",{class:"q-field__prepend q-field__marginal row no-wrap items-center",key:"prepend",onClick:F},r.prepend())),l.push(a("div",{class:"q-field__control-container col relative-position row no-wrap q-anchor--skip"},Y())),m.value===!0&&o.noErrorIcon===!1&&l.push(k("error",[a(K,{name:n.iconSet.field.error,color:"negative"})])),o.loading===!0||e.innerLoading.value===!0?l.push(k("inner-loading-append",r.loading!==void 0?r.loading():[a(de,{color:o.color})])):o.clearable===!0&&e.hasValue.value===!0&&e.editable.value===!0&&l.push(k("inner-clearable-append",[a(K,{class:"q-field__focusable-action",name:o.clearIcon||n.iconSet.field.clear,tabindex:0,role:"button","aria-hidden":"false","aria-label":n.lang.label.clear,onKeyup:W,onClick:D})])),r.append!==void 0&&l.push(a("div",{class:"q-field__append q-field__marginal row no-wrap items-center",key:"append",onClick:F},r.append())),e.getInnerAppend!==void 0&&l.push(k("inner-append",e.getInnerAppend())),e.getControlChild!==void 0&&l.push(e.getControlChild()),l}function Y(){const l=[];return o.prefix!==void 0&&o.prefix!==null&&l.push(a("div",{class:"q-field__prefix no-pointer-events row items-center"},o.prefix)),e.getShadowControl!==void 0&&e.hasShadow.value===!0&&l.push(e.getShadowControl()),e.getControl!==void 0?l.push(e.getControl()):r.rawControl!==void 0?l.push(r.rawControl()):r.control!==void 0&&l.push(a("div",{ref:e.targetRef,class:"q-field__native row",tabindex:-1,...e.splitAttrs.attributes.value,"data-autofocus":o.autofocus===!0||void 0},r.control(q.value))),S.value===!0&&l.push(a("div",{class:O.value},$(r.label,o.label))),o.suffix!==void 0&&o.suffix!==null&&l.push(a("div",{class:"q-field__suffix no-pointer-events row items-center"},o.suffix)),l.concat($(r.default))}function ee(){let l,u;m.value===!0?y.value!==null?(l=[a("div",{role:"alert"},y.value)],u=`q--slot-error-${y.value}`):(l=$(r.error),u="q--slot-error"):(o.hideHint!==!0||e.focused.value===!0)&&(o.hint!==void 0?(l=[a("div",o.hint)],u=`q--slot-hint-${o.hint}`):(l=$(r.hint),u="q--slot-hint"));const U=o.counter===!0||r.counter!==void 0;if(o.hideBottomSpace===!0&&U===!1&&l===void 0)return;const H=a("div",{key:u,class:"q-field__messages col"},l);return a("div",{class:"q-field__bottom row items-start q-field__bottom--"+(o.hideBottomSpace!==!0?"animated":"stale"),onClick:F},[o.hideBottomSpace===!0?H:a(fe,{name:"q-transition--field-message"},()=>H),U===!0?a("div",{class:"q-field__counter"},r.counter!==void 0?r.counter():e.computedCounter.value):null])}function k(l,u){return u===null?null:a("div",{key:l,class:"q-field__append q-field__marginal row no-wrap items-center q-anchor--skip"},u)}let L=!1;return ie(()=>{L=!0}),se(()=>{L===!0&&o.autofocus===!0&&i.focus()}),o.autofocus===!0&&G(()=>{i.focus()}),T(()=>{c!==null&&clearTimeout(c)}),Object.assign(i,{focus:v,blur:p}),function(){const u=e.getControl===void 0&&r.control===void 0?{...e.splitAttrs.attributes.value,"data-autofocus":o.autofocus===!0||void 0,...B.value}:B.value;return a(e.tag.value,{ref:e.rootRef,class:[C.value,f.class],style:f.style,...u},[r.before!==void 0?a("div",{class:"q-field__before q-field__marginal row no-wrap items-center",onClick:F},r.before()):null,a("div",{class:"q-field__inner relative-position col self-stretch"},[a("div",{ref:e.controlRef,class:h.value,tabindex:-1,...e.controlEvents},X()),_.value===!0?ee():null]),r.after!==void 0?a("div",{class:"q-field__after q-field__marginal row no-wrap items-center",onClick:F},r.after()):null])}}const De={name:String};function Me(e={}){return(o,t,r)=>{o[t](a("input",{class:"hidden"+(r||""),...e.value}))}}function Te(e){return s(()=>e.name||e.for)}const Be=/[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]/,Re=/[\u4e00-\u9fff\u3400-\u4dbf\u{20000}-\u{2a6df}\u{2a700}-\u{2b73f}\u{2b740}-\u{2b81f}\u{2b820}-\u{2ceaf}\uf900-\ufaff\u3300-\u33ff\ufe30-\ufe4f\uf900-\ufaff\u{2f800}-\u{2fa1f}]/u,Ve=/[\u3131-\u314e\u314f-\u3163\uac00-\ud7a3]/,Ae=/[a-z0-9_ -]$/i;function ze(e){return function(t){if(t.type==="compositionend"||t.type==="change"){if(t.target.qComposing!==!0)return;t.target.qComposing=!1,e(t)}else t.type==="compositionupdate"&&t.target.qComposing!==!0&&typeof t.data=="string"&&(ce.is.firefox===!0?Ae.test(t.data)===!1:Be.test(t.data)===!0||Re.test(t.data)===!0||Ve.test(t.data)===!0)===!0&&(t.target.qComposing=!0)}}export{De as a,Ee as b,Te as c,Pe as d,ze as e,xe as f,Oe as g,Me as h,Ie as u};