@weni/unnnic-system 3.31.1-alpha.0 → 3.31.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -2
- package/dist/unnnic.mjs +5 -5
- package/dist/unnnic.umd.js +1 -1
- package/package.json +1 -1
- package/src/utils/sanitize.js +5 -18
package/dist/index.d.ts
CHANGED
|
@@ -160,10 +160,9 @@ declare interface FormElementProps {
|
|
|
160
160
|
*
|
|
161
161
|
* @param {string} input
|
|
162
162
|
* @param {Array<string>} allowedTags - List of allowed HTML tags.
|
|
163
|
-
* @param {number} maxLength - Maximum length of the sanitized string.
|
|
164
163
|
* @returns {string}
|
|
165
164
|
*/
|
|
166
|
-
declare function fullySanitize(input: string, allowedTags?: Array<string
|
|
165
|
+
declare function fullySanitize(input: string, allowedTags?: Array<string>): string;
|
|
167
166
|
|
|
168
167
|
declare interface IconProps {
|
|
169
168
|
filled?: boolean;
|
package/dist/unnnic.mjs
CHANGED
|
@@ -4,13 +4,13 @@ const Es = 16;
|
|
|
4
4
|
function H2(e) {
|
|
5
5
|
return typeof e != "string" ? "" : e.replace(/<\/?[a-zA-Z]+\b[^>]*>/g, "");
|
|
6
6
|
}
|
|
7
|
-
function $w(e, a = []
|
|
8
|
-
return typeof e != "string" ? "" : (e
|
|
7
|
+
function $w(e, a = []) {
|
|
8
|
+
return typeof e != "string" ? "" : (e = H2(e), e = e.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi, (t, i) => a.includes(i.toLowerCase()) ? t : ""), e);
|
|
9
9
|
}
|
|
10
|
-
function Kn(e, a = []
|
|
10
|
+
function Kn(e, a = []) {
|
|
11
11
|
if (typeof e != "string") return "";
|
|
12
|
-
let
|
|
13
|
-
return H2(
|
|
12
|
+
let t = $w(e, a);
|
|
13
|
+
return H2(t);
|
|
14
14
|
}
|
|
15
15
|
function Ki(e, a) {
|
|
16
16
|
const t = typeof e == "string" && !a ? `${e}Context` : a, i = Symbol(t);
|
package/dist/unnnic.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(x,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(x=typeof globalThis<"u"?globalThis:x||self,t(x.Unnnic={},x.Vue))})(this,function(x,t){"use strict";function r3(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const Qo=r3(t),Gr=16;function pf(e){return typeof e!="string"?"":e.replace(/<\/?[a-zA-Z]+\b[^>]*>/g,"")}function o3(e,n=[],a=1e3){return typeof e!="string"?"":(e.length>a&&(e=e.substring(0,a)),e=pf(e),e=e.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(i,r)=>n.includes(r.toLowerCase())?i:""),e)}function Jn(e,n=[],a=1e3){if(typeof e!="string")return"";let i=o3(e,n,a);return pf(i)}function on(e,n){const a=typeof e=="string"&&!n?`${e}Context`:n,i=Symbol(a);return[l=>{const d=t.inject(i,l);if(d||d===null)return d;throw new Error(`Injection \`${i.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(", ")}`:`\`${e}\``}`)},l=>(t.provide(i,l),l)]}function sn(){let e=document.activeElement;if(e==null)return null;for(;e!=null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function bf(e,n,a){const i=a.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});n&&i.addEventListener(e,n,{once:!0}),i.dispatchEvent(r)}function wu(e){return e?e.flatMap(n=>n.type===t.Fragment?wu(n.children):[n]):[]}const[Du]=on("ConfigProvider");function s3(e,n){var a;const i=t.shallowRef();return t.watchEffect(()=>{i.value=e()},{...n,flush:(a=void 0)!=null?a:"sync"}),t.readonly(i)}function Wr(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function l3(){const e=new Set,n=s=>{e.delete(s)};return{on:s=>{e.add(s);const l=()=>n(s);return Wr(l),{off:l}},off:n,trigger:(...s)=>Promise.all(Array.from(e).map(l=>l(...s))),clear:()=>{e.clear()}}}function u3(e){let n=!1,a;const i=t.effectScope(!0);return(...r)=>(n||(a=i.run(()=>e(...r)),n=!0),a)}function d3(e){let n=0,a,i;const r=()=>{n-=1,i&&n<=0&&(i.stop(),a=void 0,i=void 0)};return(...s)=>(n+=1,i||(i=t.effectScope(!0),a=i.run(()=>e(...s))),Wr(r),a)}function c3(e){if(!t.isRef(e))return t.reactive(e);const n=new Proxy({},{get(a,i,r){return t.unref(Reflect.get(e.value,i,r))},set(a,i,r){return t.isRef(e.value[i])&&!t.isRef(r)?e.value[i].value=r:e.value[i]=r,!0},deleteProperty(a,i){return Reflect.deleteProperty(e.value,i)},has(a,i){return Reflect.has(e.value,i)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return t.reactive(n)}function f3(e){return c3(t.computed(e))}function _3(e,...n){const a=n.flat(),i=a[0];return f3(()=>Object.fromEntries(typeof i=="function"?Object.entries(t.toRefs(e)).filter(([r,s])=>!i(t.toValue(s),r)):Object.entries(t.toRefs(e)).filter(r=>!a.includes(r[0]))))}const Cn=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const g3=e=>typeof e<"u",h3=Object.prototype.toString,m3=e=>h3.call(e)==="[object Object]",yf=F3();function F3(){var e,n;return Cn&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window==null?void 0:window.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function p3(e){return t.getCurrentInstance()}function Cu(e){return Array.isArray(e)?e:[e]}function b3(e,n=1e4){return t.customRef((a,i)=>{let r=t.toValue(e),s;const l=()=>setTimeout(()=>{r=t.toValue(e),i()},t.toValue(n));return Wr(()=>{clearTimeout(s)}),{get(){return a(),r},set(d){r=d,i(),clearTimeout(s),s=l()}}})}function y3(e,n){p3()&&t.onBeforeUnmount(e,n)}function kf(e,n,a={}){const{immediate:i=!0,immediateCallback:r=!1}=a,s=t.shallowRef(!1);let l=null;function d(){l&&(clearTimeout(l),l=null)}function c(){s.value=!1,d()}function _(...g){r&&e(),d(),s.value=!0,l=setTimeout(()=>{s.value=!1,l=null,e(...g)},t.toValue(n))}return i&&(s.value=!0,Cn&&_()),Wr(c),{isPending:t.readonly(s),start:_,stop:c}}function k3(e,n,a){return t.watch(e,n,{...a,immediate:!0})}const Eu=Cn?window:void 0;function Gi(e){var n;const a=t.toValue(e);return(n=a==null?void 0:a.$el)!=null?n:a}function Xo(...e){const n=[],a=()=>{n.forEach(d=>d()),n.length=0},i=(d,c,_,g)=>(d.addEventListener(c,_,g),()=>d.removeEventListener(c,_,g)),r=t.computed(()=>{const d=Cu(t.toValue(e[0])).filter(c=>c!=null);return d.every(c=>typeof c!="string")?d:void 0}),s=k3(()=>{var d,c;return[(c=(d=r.value)==null?void 0:d.map(_=>Gi(_)))!=null?c:[Eu].filter(_=>_!=null),Cu(t.toValue(r.value?e[1]:e[0])),Cu(t.unref(r.value?e[2]:e[1])),t.toValue(r.value?e[3]:e[2])]},([d,c,_,g])=>{if(a(),!(d!=null&&d.length)||!(c!=null&&c.length)||!(_!=null&&_.length))return;const h=m3(g)?{...g}:g;n.push(...d.flatMap(F=>c.flatMap(p=>_.map(y=>i(F,p,y,h)))))},{flush:"post"}),l=()=>{s(),a()};return Wr(a),l}function w3(){const e=t.shallowRef(!1),n=t.getCurrentInstance();return n&&t.onMounted(()=>{e.value=!0},n),e}function D3(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function C3(...e){let n,a,i={};e.length===3?(n=e[0],a=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,a=e[0],i=e[1]):(n=e[0],a=e[1]):(n=!0,a=e[0]);const{target:r=Eu,eventName:s="keydown",passive:l=!1,dedupe:d=!1}=i,c=D3(n);return Xo(r,s,g=>{g.repeat&&t.toValue(d)||c(g)&&a(g)},l)}function E3(e){return JSON.parse(JSON.stringify(e))}function Qr(e,n,a,i={}){var r,s,l;const{clone:d=!1,passive:c=!1,eventName:_,deep:g=!1,defaultValue:h,shouldEmit:F}=i,p=t.getCurrentInstance(),y=a||(p==null?void 0:p.emit)||((r=p==null?void 0:p.$emit)==null?void 0:r.bind(p))||((l=(s=p==null?void 0:p.proxy)==null?void 0:s.$emit)==null?void 0:l.bind(p==null?void 0:p.proxy));let w=_;n||(n="modelValue"),w=w||`update:${n.toString()}`;const C=D=>d?typeof d=="function"?d(D):E3(D):D,q=()=>g3(e[n])?C(e[n]):h,B=D=>{F?F(D)&&y(w,D):y(w,D)};if(c){const D=q(),A=t.ref(D);let S=!1;return t.watch(()=>e[n],I=>{S||(S=!0,A.value=C(I),t.nextTick(()=>S=!1))}),t.watch(A,I=>{!S&&(I!==e[n]||g)&&B(I)},{deep:g}),A}else return t.computed({get(){return q()},set(D){B(D)}})}function Au(e){if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)==="[object Module]":!0}function Bu(e,n,a=".",i){if(!Au(n))return Bu(e,{},a,i);const r=Object.assign({},n);for(const s in e){if(s==="__proto__"||s==="constructor")continue;const l=e[s];l!=null&&(i&&i(r,s,l,a)||(Array.isArray(l)&&Array.isArray(r[s])?r[s]=[...l,...r[s]]:Au(l)&&Au(r[s])?r[s]=Bu(l,r[s],(a?`${a}.`:"")+s.toString(),i):r[s]=l))}return r}function A3(e){return(...n)=>n.reduce((a,i)=>Bu(a,i,"",e),{})}const B3=A3(),x3=d3(()=>{const e=t.ref(new Map),n=t.ref(),a=t.computed(()=>{for(const l of e.value.values())if(l)return!0;return!1}),i=Du({scrollBody:t.ref(!0)});let r=null;const s=()=>{document.body.style.paddingRight="",document.body.style.marginRight="",document.body.style.pointerEvents="",document.documentElement.style.removeProperty("--scrollbar-width"),document.body.style.overflow=n.value??"",yf&&(r==null||r()),n.value=void 0};return t.watch(a,(l,d)=>{var h;if(!Cn)return;if(!l){d&&s();return}n.value===void 0&&(n.value=document.body.style.overflow);const c=window.innerWidth-document.documentElement.clientWidth,_={padding:c,margin:0},g=(h=i.scrollBody)!=null&&h.value?typeof i.scrollBody.value=="object"?B3({padding:i.scrollBody.value.padding===!0?c:i.scrollBody.value.padding,margin:i.scrollBody.value.margin===!0?c:i.scrollBody.value.margin},_):_:{padding:0,margin:0};c>0&&(document.body.style.paddingRight=typeof g.padding=="number"?`${g.padding}px`:String(g.padding),document.body.style.marginRight=typeof g.margin=="number"?`${g.margin}px`:String(g.margin),document.documentElement.style.setProperty("--scrollbar-width",`${c}px`),document.body.style.overflow="hidden"),yf&&(r=Xo(document,"touchmove",F=>v3(F),{passive:!1})),t.nextTick(()=>{document.body.style.pointerEvents="none",document.body.style.overflow="hidden"})},{immediate:!0,flush:"sync"}),e});function wf(e){const n=Math.random().toString(36).substring(2,7),a=x3();a.value.set(n,e);const i=t.computed({get:()=>a.value.get(n)??!1,set:r=>a.value.set(n,r)});return y3(()=>{a.value.delete(n)}),i}function Df(e){const n=window.getComputedStyle(e);if(n.overflowX==="scroll"||n.overflowY==="scroll"||n.overflowX==="auto"&&e.clientWidth<e.scrollWidth||n.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const a=e.parentNode;return!(a instanceof Element)||a.tagName==="BODY"?!1:Df(a)}}function v3(e){const n=e||window.event,a=n.target;return a instanceof Element&&Df(a)?!1:n.touches.length>1?!0:(n.preventDefault&&n.cancelable&&n.preventDefault(),!1)}function Cf(e){const n=Du({dir:t.ref("ltr")});return t.computed(()=>{var a;return(e==null?void 0:e.value)||((a=n.dir)==null?void 0:a.value)||"ltr"})}function Ko(e){const n=t.getCurrentInstance(),a=n==null?void 0:n.type.emits,i={};return a!=null&&a.length||console.warn(`No emitted event found. Please check component: ${n==null?void 0:n.type.__name}`),a==null||a.forEach(r=>{i[t.toHandlerKey(t.camelize(r))]=(...s)=>e(r,...s)}),i}let xu=0;function S3(){t.watchEffect(e=>{if(!Cn)return;const n=document.querySelectorAll("[data-reka-focus-guard]");document.body.insertAdjacentElement("afterbegin",n[0]??Ef()),document.body.insertAdjacentElement("beforeend",n[1]??Ef()),xu++,e(()=>{xu===1&&document.querySelectorAll("[data-reka-focus-guard]").forEach(a=>a.remove()),xu--})})}function Ef(){const e=document.createElement("span");return e.setAttribute("data-reka-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}function nt(){const e=t.getCurrentInstance(),n=t.ref(),a=t.computed(()=>{var l,d;return["#text","#comment"].includes((l=n.value)==null?void 0:l.$el.nodeName)?(d=n.value)==null?void 0:d.$el.nextElementSibling:Gi(n)}),i=Object.assign({},e.exposed),r={};for(const l in e.props)Object.defineProperty(r,l,{enumerable:!0,configurable:!0,get:()=>e.props[l]});if(Object.keys(i).length>0)for(const l in i)Object.defineProperty(r,l,{enumerable:!0,configurable:!0,get:()=>i[l]});Object.defineProperty(r,"$el",{enumerable:!0,configurable:!0,get:()=>e.vnode.el}),e.exposed=r;function s(l){n.value=l,l&&(Object.defineProperty(r,"$el",{enumerable:!0,configurable:!0,get:()=>l instanceof Element?l:l.$el}),e.exposed=r)}return{forwardRef:s,currentRef:n,currentElement:a}}function Wi(e){const n=t.getCurrentInstance(),a=Object.keys((n==null?void 0:n.type.props)??{}).reduce((r,s)=>{const l=(n==null?void 0:n.type.props[s]).default;return l!==void 0&&(r[s]=l),r},{}),i=t.toRef(e);return t.computed(()=>{const r={},s=(n==null?void 0:n.vnode.props)??{};return Object.keys(s).forEach(l=>{r[t.camelize(l)]=s[l]}),Object.keys({...a,...r}).reduce((l,d)=>(i.value[d]!==void 0&&(l[d]=i.value[d]),l),{})})}function ma(e,n){const a=Wi(e),i=n?Ko(n):{};return t.computed(()=>({...a.value,...i}))}function j3(e,n){const a=b3(!1,300),i=t.ref(null),r=l3();function s(){i.value=null,a.value=!1}function l(d,c){const _=d.currentTarget,g={x:d.clientX,y:d.clientY},h=q3(g,_.getBoundingClientRect()),F=I3(g,h),p=N3(c.getBoundingClientRect()),y=O3([...F,...p]);i.value=y,a.value=!0}return t.watchEffect(d=>{if(e.value&&n.value){const c=g=>l(g,n.value),_=g=>l(g,e.value);e.value.addEventListener("pointerleave",c),n.value.addEventListener("pointerleave",_),d(()=>{var g,h;(g=e.value)==null||g.removeEventListener("pointerleave",c),(h=n.value)==null||h.removeEventListener("pointerleave",_)})}}),t.watchEffect(d=>{var c;if(i.value){const _=g=>{var C,q;if(!i.value||!(g.target instanceof Element))return;const h=g.target,F={x:g.clientX,y:g.clientY},p=((C=e.value)==null?void 0:C.contains(h))||((q=n.value)==null?void 0:q.contains(h)),y=!T3(F,i.value),w=!!h.closest("[data-grace-area-trigger]");p?s():(y||w)&&(s(),r.trigger())};(c=e.value)==null||c.ownerDocument.addEventListener("pointermove",_),d(()=>{var g;return(g=e.value)==null?void 0:g.ownerDocument.removeEventListener("pointermove",_)})}}),{isPointerInTransit:a,onPointerExit:r.on}}function q3(e,n){const a=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),r=Math.abs(n.right-e.x),s=Math.abs(n.left-e.x);switch(Math.min(a,i,r,s)){case s:return"left";case r:return"right";case a:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function I3(e,n,a=5){const i=[];switch(n){case"top":i.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":i.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":i.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":i.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return i}function N3(e){const{top:n,right:a,bottom:i,left:r}=e;return[{x:r,y:n},{x:a,y:n},{x:a,y:i},{x:r,y:i}]}function T3(e,n){const{x:a,y:i}=e;let r=!1;for(let s=0,l=n.length-1;s<n.length;l=s++){const d=n[s].x,c=n[s].y,_=n[l].x,g=n[l].y;c>i!=g>i&&a<(_-d)*(i-c)/(g-c)+d&&(r=!r)}return r}function O3(e){const n=e.slice();return n.sort((a,i)=>a.x<i.x?-1:a.x>i.x?1:a.y<i.y?-1:a.y>i.y?1:0),M3(n)}function M3(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))n.pop();else break}n.push(r)}n.pop();const a=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;a.length>=2;){const s=a[a.length-1],l=a[a.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))a.pop();else break}a.push(r)}return a.pop(),n.length===1&&a.length===1&&n[0].x===a[0].x&&n[0].y===a[0].y?n:n.concat(a)}var P3=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Qi=new WeakMap,Zo=new WeakMap,Jo={},vu=0,Af=function(e){return e&&(e.host||Af(e.parentNode))},L3=function(e,n){return n.map(function(a){if(e.contains(a))return a;var i=Af(a);return i&&e.contains(i)?i:(console.error("aria-hidden",a,"in not contained inside",e,". Doing nothing"),null)}).filter(function(a){return!!a})},z3=function(e,n,a,i){var r=L3(n,Array.isArray(e)?e:[e]);Jo[a]||(Jo[a]=new WeakMap);var s=Jo[a],l=[],d=new Set,c=new Set(r),_=function(h){!h||d.has(h)||(d.add(h),_(h.parentNode))};r.forEach(_);var g=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(F){if(d.has(F))g(F);else try{var p=F.getAttribute(i),y=p!==null&&p!=="false",w=(Qi.get(F)||0)+1,C=(s.get(F)||0)+1;Qi.set(F,w),s.set(F,C),l.push(F),w===1&&y&&Zo.set(F,!0),C===1&&F.setAttribute(a,"true"),y||F.setAttribute(i,"true")}catch(q){console.error("aria-hidden: cannot operate on ",F,q)}})};return g(n),d.clear(),vu++,function(){l.forEach(function(h){var F=Qi.get(h)-1,p=s.get(h)-1;Qi.set(h,F),s.set(h,p),F||(Zo.has(h)||h.removeAttribute(i),Zo.delete(h)),p||h.removeAttribute(a)}),vu--,vu||(Qi=new WeakMap,Qi=new WeakMap,Zo=new WeakMap,Jo={})}},V3=function(e,n,a){a===void 0&&(a="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=P3(e);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),z3(i,r,a,"aria-hidden")):function(){return null}};function Bf(e){let n;t.watch(()=>Gi(e),a=>{a?n=V3(a):n&&n()}),t.onUnmounted(()=>{n&&n()})}let R3=0;function $n(e,n="reka"){var i;if("useId"in Qo)return`${n}-${(i=Qo.useId)==null?void 0:i.call(Qo)}`;const a=Du({useId:void 0});return a.useId?`${n}-${a.useId()}`:`${n}-${++R3}`}function U3(e){const n=t.ref(),a=t.computed(()=>{var r;return((r=n.value)==null?void 0:r.width)??0}),i=t.computed(()=>{var r;return((r=n.value)==null?void 0:r.height)??0});return t.onMounted(()=>{const r=Gi(e);if(r){n.value={width:r.offsetWidth,height:r.offsetHeight};const s=new ResizeObserver(l=>{if(!Array.isArray(l)||!l.length)return;const d=l[0];let c,_;if("borderBoxSize"in d){const g=d.borderBoxSize,h=Array.isArray(g)?g[0]:g;c=h.inlineSize,_=h.blockSize}else c=r.offsetWidth,_=r.offsetHeight;n.value={width:c,height:_}});return s.observe(r,{box:"border-box"}),()=>s.unobserve(r)}else n.value=void 0}),{width:a,height:i}}function H3(e,n){const a=t.ref(e);function i(s){return n[a.value][s]??a.value}return{state:a,dispatch:s=>{a.value=i(s)}}}function Y3(e,n){var C;const a=t.ref({}),i=t.ref("none"),r=t.ref(e),s=e.value?"mounted":"unmounted";let l;const d=((C=n.value)==null?void 0:C.ownerDocument.defaultView)??Eu,{state:c,dispatch:_}=H3(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}}),g=q=>{var B;if(Cn){const D=new CustomEvent(q,{bubbles:!1,cancelable:!1});(B=n.value)==null||B.dispatchEvent(D)}};t.watch(e,async(q,B)=>{var A;const D=B!==q;if(await t.nextTick(),D){const S=i.value,I=$o(n.value);q?(_("MOUNT"),g("enter"),I==="none"&&g("after-enter")):I==="none"||I==="undefined"||((A=a.value)==null?void 0:A.display)==="none"?(_("UNMOUNT"),g("leave"),g("after-leave")):B&&S!==I?(_("ANIMATION_OUT"),g("leave")):(_("UNMOUNT"),g("after-leave"))}},{immediate:!0});const h=q=>{const B=$o(n.value),D=B.includes(CSS.escape(q.animationName)),A=c.value==="mounted"?"enter":"leave";if(q.target===n.value&&D&&(g(`after-${A}`),_("ANIMATION_END"),!r.value)){const S=n.value.style.animationFillMode;n.value.style.animationFillMode="forwards",l=d==null?void 0:d.setTimeout(()=>{var I;((I=n.value)==null?void 0:I.style.animationFillMode)==="forwards"&&(n.value.style.animationFillMode=S)})}q.target===n.value&&B==="none"&&_("ANIMATION_END")},F=q=>{q.target===n.value&&(i.value=$o(n.value))},p=t.watch(n,(q,B)=>{q?(a.value=getComputedStyle(q),q.addEventListener("animationstart",F),q.addEventListener("animationcancel",h),q.addEventListener("animationend",h)):(_("ANIMATION_END"),l!==void 0&&(d==null||d.clearTimeout(l)),B==null||B.removeEventListener("animationstart",F),B==null||B.removeEventListener("animationcancel",h),B==null||B.removeEventListener("animationend",h))},{immediate:!0}),y=t.watch(c,()=>{const q=$o(n.value);i.value=c.value==="mounted"?q:"none"});return t.onUnmounted(()=>{p(),y()}),{isPresent:t.computed(()=>["mounted","unmountSuspended"].includes(c.value))}}function $o(e){return e&&getComputedStyle(e).animationName||"none"}var Xr=t.defineComponent({name:"Presence",props:{present:{type:Boolean,required:!0},forceMount:{type:Boolean}},slots:{},setup(e,{slots:n,expose:a}){var _;const{present:i,forceMount:r}=t.toRefs(e),s=t.ref(),{isPresent:l}=Y3(i,s);a({present:l});let d=n.default({present:l.value});d=wu(d||[]);const c=t.getCurrentInstance();if(d&&(d==null?void 0:d.length)>1){const g=(_=c==null?void 0:c.parent)!=null&&_.type.name?`<${c.parent.type.name} />`:"component";throw new Error([`Detected an invalid children for \`${g}\` for \`Presence\` component.`,"","Note: Presence works similarly to `v-if` directly, but it waits for animation/transition to finished before unmounting. So it expect only one direct child of valid VNode type.","You can apply a few solutions:",["Provide a single child element so that `presence` directive attach correctly.","Ensure the first child is an actual element instead of a raw text node or comment node."].map(h=>` - ${h}`).join(`
|
|
1
|
+
(function(x,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(x=typeof globalThis<"u"?globalThis:x||self,t(x.Unnnic={},x.Vue))})(this,function(x,t){"use strict";function r3(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const Qo=r3(t),Gr=16;function pf(e){return typeof e!="string"?"":e.replace(/<\/?[a-zA-Z]+\b[^>]*>/g,"")}function o3(e,n=[]){return typeof e!="string"?"":(e=pf(e),e=e.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(a,i)=>n.includes(i.toLowerCase())?a:""),e)}function Jn(e,n=[]){if(typeof e!="string")return"";let a=o3(e,n);return pf(a)}function on(e,n){const a=typeof e=="string"&&!n?`${e}Context`:n,i=Symbol(a);return[l=>{const d=t.inject(i,l);if(d||d===null)return d;throw new Error(`Injection \`${i.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(", ")}`:`\`${e}\``}`)},l=>(t.provide(i,l),l)]}function sn(){let e=document.activeElement;if(e==null)return null;for(;e!=null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function bf(e,n,a){const i=a.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});n&&i.addEventListener(e,n,{once:!0}),i.dispatchEvent(r)}function wu(e){return e?e.flatMap(n=>n.type===t.Fragment?wu(n.children):[n]):[]}const[Du]=on("ConfigProvider");function s3(e,n){var a;const i=t.shallowRef();return t.watchEffect(()=>{i.value=e()},{...n,flush:(a=void 0)!=null?a:"sync"}),t.readonly(i)}function Wr(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function l3(){const e=new Set,n=s=>{e.delete(s)};return{on:s=>{e.add(s);const l=()=>n(s);return Wr(l),{off:l}},off:n,trigger:(...s)=>Promise.all(Array.from(e).map(l=>l(...s))),clear:()=>{e.clear()}}}function u3(e){let n=!1,a;const i=t.effectScope(!0);return(...r)=>(n||(a=i.run(()=>e(...r)),n=!0),a)}function d3(e){let n=0,a,i;const r=()=>{n-=1,i&&n<=0&&(i.stop(),a=void 0,i=void 0)};return(...s)=>(n+=1,i||(i=t.effectScope(!0),a=i.run(()=>e(...s))),Wr(r),a)}function c3(e){if(!t.isRef(e))return t.reactive(e);const n=new Proxy({},{get(a,i,r){return t.unref(Reflect.get(e.value,i,r))},set(a,i,r){return t.isRef(e.value[i])&&!t.isRef(r)?e.value[i].value=r:e.value[i]=r,!0},deleteProperty(a,i){return Reflect.deleteProperty(e.value,i)},has(a,i){return Reflect.has(e.value,i)},ownKeys(){return Object.keys(e.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return t.reactive(n)}function f3(e){return c3(t.computed(e))}function _3(e,...n){const a=n.flat(),i=a[0];return f3(()=>Object.fromEntries(typeof i=="function"?Object.entries(t.toRefs(e)).filter(([r,s])=>!i(t.toValue(s),r)):Object.entries(t.toRefs(e)).filter(r=>!a.includes(r[0]))))}const Cn=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const g3=e=>typeof e<"u",h3=Object.prototype.toString,m3=e=>h3.call(e)==="[object Object]",yf=F3();function F3(){var e,n;return Cn&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window==null?void 0:window.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function p3(e){return t.getCurrentInstance()}function Cu(e){return Array.isArray(e)?e:[e]}function b3(e,n=1e4){return t.customRef((a,i)=>{let r=t.toValue(e),s;const l=()=>setTimeout(()=>{r=t.toValue(e),i()},t.toValue(n));return Wr(()=>{clearTimeout(s)}),{get(){return a(),r},set(d){r=d,i(),clearTimeout(s),s=l()}}})}function y3(e,n){p3()&&t.onBeforeUnmount(e,n)}function kf(e,n,a={}){const{immediate:i=!0,immediateCallback:r=!1}=a,s=t.shallowRef(!1);let l=null;function d(){l&&(clearTimeout(l),l=null)}function c(){s.value=!1,d()}function _(...g){r&&e(),d(),s.value=!0,l=setTimeout(()=>{s.value=!1,l=null,e(...g)},t.toValue(n))}return i&&(s.value=!0,Cn&&_()),Wr(c),{isPending:t.readonly(s),start:_,stop:c}}function k3(e,n,a){return t.watch(e,n,{...a,immediate:!0})}const Eu=Cn?window:void 0;function Gi(e){var n;const a=t.toValue(e);return(n=a==null?void 0:a.$el)!=null?n:a}function Xo(...e){const n=[],a=()=>{n.forEach(d=>d()),n.length=0},i=(d,c,_,g)=>(d.addEventListener(c,_,g),()=>d.removeEventListener(c,_,g)),r=t.computed(()=>{const d=Cu(t.toValue(e[0])).filter(c=>c!=null);return d.every(c=>typeof c!="string")?d:void 0}),s=k3(()=>{var d,c;return[(c=(d=r.value)==null?void 0:d.map(_=>Gi(_)))!=null?c:[Eu].filter(_=>_!=null),Cu(t.toValue(r.value?e[1]:e[0])),Cu(t.unref(r.value?e[2]:e[1])),t.toValue(r.value?e[3]:e[2])]},([d,c,_,g])=>{if(a(),!(d!=null&&d.length)||!(c!=null&&c.length)||!(_!=null&&_.length))return;const h=m3(g)?{...g}:g;n.push(...d.flatMap(F=>c.flatMap(p=>_.map(y=>i(F,p,y,h)))))},{flush:"post"}),l=()=>{s(),a()};return Wr(a),l}function w3(){const e=t.shallowRef(!1),n=t.getCurrentInstance();return n&&t.onMounted(()=>{e.value=!0},n),e}function D3(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function C3(...e){let n,a,i={};e.length===3?(n=e[0],a=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,a=e[0],i=e[1]):(n=e[0],a=e[1]):(n=!0,a=e[0]);const{target:r=Eu,eventName:s="keydown",passive:l=!1,dedupe:d=!1}=i,c=D3(n);return Xo(r,s,g=>{g.repeat&&t.toValue(d)||c(g)&&a(g)},l)}function E3(e){return JSON.parse(JSON.stringify(e))}function Qr(e,n,a,i={}){var r,s,l;const{clone:d=!1,passive:c=!1,eventName:_,deep:g=!1,defaultValue:h,shouldEmit:F}=i,p=t.getCurrentInstance(),y=a||(p==null?void 0:p.emit)||((r=p==null?void 0:p.$emit)==null?void 0:r.bind(p))||((l=(s=p==null?void 0:p.proxy)==null?void 0:s.$emit)==null?void 0:l.bind(p==null?void 0:p.proxy));let w=_;n||(n="modelValue"),w=w||`update:${n.toString()}`;const C=D=>d?typeof d=="function"?d(D):E3(D):D,q=()=>g3(e[n])?C(e[n]):h,B=D=>{F?F(D)&&y(w,D):y(w,D)};if(c){const D=q(),A=t.ref(D);let S=!1;return t.watch(()=>e[n],I=>{S||(S=!0,A.value=C(I),t.nextTick(()=>S=!1))}),t.watch(A,I=>{!S&&(I!==e[n]||g)&&B(I)},{deep:g}),A}else return t.computed({get(){return q()},set(D){B(D)}})}function Au(e){if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)==="[object Module]":!0}function Bu(e,n,a=".",i){if(!Au(n))return Bu(e,{},a,i);const r=Object.assign({},n);for(const s in e){if(s==="__proto__"||s==="constructor")continue;const l=e[s];l!=null&&(i&&i(r,s,l,a)||(Array.isArray(l)&&Array.isArray(r[s])?r[s]=[...l,...r[s]]:Au(l)&&Au(r[s])?r[s]=Bu(l,r[s],(a?`${a}.`:"")+s.toString(),i):r[s]=l))}return r}function A3(e){return(...n)=>n.reduce((a,i)=>Bu(a,i,"",e),{})}const B3=A3(),x3=d3(()=>{const e=t.ref(new Map),n=t.ref(),a=t.computed(()=>{for(const l of e.value.values())if(l)return!0;return!1}),i=Du({scrollBody:t.ref(!0)});let r=null;const s=()=>{document.body.style.paddingRight="",document.body.style.marginRight="",document.body.style.pointerEvents="",document.documentElement.style.removeProperty("--scrollbar-width"),document.body.style.overflow=n.value??"",yf&&(r==null||r()),n.value=void 0};return t.watch(a,(l,d)=>{var h;if(!Cn)return;if(!l){d&&s();return}n.value===void 0&&(n.value=document.body.style.overflow);const c=window.innerWidth-document.documentElement.clientWidth,_={padding:c,margin:0},g=(h=i.scrollBody)!=null&&h.value?typeof i.scrollBody.value=="object"?B3({padding:i.scrollBody.value.padding===!0?c:i.scrollBody.value.padding,margin:i.scrollBody.value.margin===!0?c:i.scrollBody.value.margin},_):_:{padding:0,margin:0};c>0&&(document.body.style.paddingRight=typeof g.padding=="number"?`${g.padding}px`:String(g.padding),document.body.style.marginRight=typeof g.margin=="number"?`${g.margin}px`:String(g.margin),document.documentElement.style.setProperty("--scrollbar-width",`${c}px`),document.body.style.overflow="hidden"),yf&&(r=Xo(document,"touchmove",F=>v3(F),{passive:!1})),t.nextTick(()=>{document.body.style.pointerEvents="none",document.body.style.overflow="hidden"})},{immediate:!0,flush:"sync"}),e});function wf(e){const n=Math.random().toString(36).substring(2,7),a=x3();a.value.set(n,e);const i=t.computed({get:()=>a.value.get(n)??!1,set:r=>a.value.set(n,r)});return y3(()=>{a.value.delete(n)}),i}function Df(e){const n=window.getComputedStyle(e);if(n.overflowX==="scroll"||n.overflowY==="scroll"||n.overflowX==="auto"&&e.clientWidth<e.scrollWidth||n.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const a=e.parentNode;return!(a instanceof Element)||a.tagName==="BODY"?!1:Df(a)}}function v3(e){const n=e||window.event,a=n.target;return a instanceof Element&&Df(a)?!1:n.touches.length>1?!0:(n.preventDefault&&n.cancelable&&n.preventDefault(),!1)}function Cf(e){const n=Du({dir:t.ref("ltr")});return t.computed(()=>{var a;return(e==null?void 0:e.value)||((a=n.dir)==null?void 0:a.value)||"ltr"})}function Ko(e){const n=t.getCurrentInstance(),a=n==null?void 0:n.type.emits,i={};return a!=null&&a.length||console.warn(`No emitted event found. Please check component: ${n==null?void 0:n.type.__name}`),a==null||a.forEach(r=>{i[t.toHandlerKey(t.camelize(r))]=(...s)=>e(r,...s)}),i}let xu=0;function S3(){t.watchEffect(e=>{if(!Cn)return;const n=document.querySelectorAll("[data-reka-focus-guard]");document.body.insertAdjacentElement("afterbegin",n[0]??Ef()),document.body.insertAdjacentElement("beforeend",n[1]??Ef()),xu++,e(()=>{xu===1&&document.querySelectorAll("[data-reka-focus-guard]").forEach(a=>a.remove()),xu--})})}function Ef(){const e=document.createElement("span");return e.setAttribute("data-reka-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}function nt(){const e=t.getCurrentInstance(),n=t.ref(),a=t.computed(()=>{var l,d;return["#text","#comment"].includes((l=n.value)==null?void 0:l.$el.nodeName)?(d=n.value)==null?void 0:d.$el.nextElementSibling:Gi(n)}),i=Object.assign({},e.exposed),r={};for(const l in e.props)Object.defineProperty(r,l,{enumerable:!0,configurable:!0,get:()=>e.props[l]});if(Object.keys(i).length>0)for(const l in i)Object.defineProperty(r,l,{enumerable:!0,configurable:!0,get:()=>i[l]});Object.defineProperty(r,"$el",{enumerable:!0,configurable:!0,get:()=>e.vnode.el}),e.exposed=r;function s(l){n.value=l,l&&(Object.defineProperty(r,"$el",{enumerable:!0,configurable:!0,get:()=>l instanceof Element?l:l.$el}),e.exposed=r)}return{forwardRef:s,currentRef:n,currentElement:a}}function Wi(e){const n=t.getCurrentInstance(),a=Object.keys((n==null?void 0:n.type.props)??{}).reduce((r,s)=>{const l=(n==null?void 0:n.type.props[s]).default;return l!==void 0&&(r[s]=l),r},{}),i=t.toRef(e);return t.computed(()=>{const r={},s=(n==null?void 0:n.vnode.props)??{};return Object.keys(s).forEach(l=>{r[t.camelize(l)]=s[l]}),Object.keys({...a,...r}).reduce((l,d)=>(i.value[d]!==void 0&&(l[d]=i.value[d]),l),{})})}function ma(e,n){const a=Wi(e),i=n?Ko(n):{};return t.computed(()=>({...a.value,...i}))}function j3(e,n){const a=b3(!1,300),i=t.ref(null),r=l3();function s(){i.value=null,a.value=!1}function l(d,c){const _=d.currentTarget,g={x:d.clientX,y:d.clientY},h=q3(g,_.getBoundingClientRect()),F=I3(g,h),p=N3(c.getBoundingClientRect()),y=O3([...F,...p]);i.value=y,a.value=!0}return t.watchEffect(d=>{if(e.value&&n.value){const c=g=>l(g,n.value),_=g=>l(g,e.value);e.value.addEventListener("pointerleave",c),n.value.addEventListener("pointerleave",_),d(()=>{var g,h;(g=e.value)==null||g.removeEventListener("pointerleave",c),(h=n.value)==null||h.removeEventListener("pointerleave",_)})}}),t.watchEffect(d=>{var c;if(i.value){const _=g=>{var C,q;if(!i.value||!(g.target instanceof Element))return;const h=g.target,F={x:g.clientX,y:g.clientY},p=((C=e.value)==null?void 0:C.contains(h))||((q=n.value)==null?void 0:q.contains(h)),y=!T3(F,i.value),w=!!h.closest("[data-grace-area-trigger]");p?s():(y||w)&&(s(),r.trigger())};(c=e.value)==null||c.ownerDocument.addEventListener("pointermove",_),d(()=>{var g;return(g=e.value)==null?void 0:g.ownerDocument.removeEventListener("pointermove",_)})}}),{isPointerInTransit:a,onPointerExit:r.on}}function q3(e,n){const a=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),r=Math.abs(n.right-e.x),s=Math.abs(n.left-e.x);switch(Math.min(a,i,r,s)){case s:return"left";case r:return"right";case a:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function I3(e,n,a=5){const i=[];switch(n){case"top":i.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":i.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":i.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":i.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return i}function N3(e){const{top:n,right:a,bottom:i,left:r}=e;return[{x:r,y:n},{x:a,y:n},{x:a,y:i},{x:r,y:i}]}function T3(e,n){const{x:a,y:i}=e;let r=!1;for(let s=0,l=n.length-1;s<n.length;l=s++){const d=n[s].x,c=n[s].y,_=n[l].x,g=n[l].y;c>i!=g>i&&a<(_-d)*(i-c)/(g-c)+d&&(r=!r)}return r}function O3(e){const n=e.slice();return n.sort((a,i)=>a.x<i.x?-1:a.x>i.x?1:a.y<i.y?-1:a.y>i.y?1:0),M3(n)}function M3(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const r=e[i];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))n.pop();else break}n.push(r)}n.pop();const a=[];for(let i=e.length-1;i>=0;i--){const r=e[i];for(;a.length>=2;){const s=a[a.length-1],l=a[a.length-2];if((s.x-l.x)*(r.y-l.y)>=(s.y-l.y)*(r.x-l.x))a.pop();else break}a.push(r)}return a.pop(),n.length===1&&a.length===1&&n[0].x===a[0].x&&n[0].y===a[0].y?n:n.concat(a)}var P3=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Qi=new WeakMap,Zo=new WeakMap,Jo={},vu=0,Af=function(e){return e&&(e.host||Af(e.parentNode))},L3=function(e,n){return n.map(function(a){if(e.contains(a))return a;var i=Af(a);return i&&e.contains(i)?i:(console.error("aria-hidden",a,"in not contained inside",e,". Doing nothing"),null)}).filter(function(a){return!!a})},z3=function(e,n,a,i){var r=L3(n,Array.isArray(e)?e:[e]);Jo[a]||(Jo[a]=new WeakMap);var s=Jo[a],l=[],d=new Set,c=new Set(r),_=function(h){!h||d.has(h)||(d.add(h),_(h.parentNode))};r.forEach(_);var g=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(F){if(d.has(F))g(F);else try{var p=F.getAttribute(i),y=p!==null&&p!=="false",w=(Qi.get(F)||0)+1,C=(s.get(F)||0)+1;Qi.set(F,w),s.set(F,C),l.push(F),w===1&&y&&Zo.set(F,!0),C===1&&F.setAttribute(a,"true"),y||F.setAttribute(i,"true")}catch(q){console.error("aria-hidden: cannot operate on ",F,q)}})};return g(n),d.clear(),vu++,function(){l.forEach(function(h){var F=Qi.get(h)-1,p=s.get(h)-1;Qi.set(h,F),s.set(h,p),F||(Zo.has(h)||h.removeAttribute(i),Zo.delete(h)),p||h.removeAttribute(a)}),vu--,vu||(Qi=new WeakMap,Qi=new WeakMap,Zo=new WeakMap,Jo={})}},V3=function(e,n,a){a===void 0&&(a="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=P3(e);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),z3(i,r,a,"aria-hidden")):function(){return null}};function Bf(e){let n;t.watch(()=>Gi(e),a=>{a?n=V3(a):n&&n()}),t.onUnmounted(()=>{n&&n()})}let R3=0;function $n(e,n="reka"){var i;if("useId"in Qo)return`${n}-${(i=Qo.useId)==null?void 0:i.call(Qo)}`;const a=Du({useId:void 0});return a.useId?`${n}-${a.useId()}`:`${n}-${++R3}`}function U3(e){const n=t.ref(),a=t.computed(()=>{var r;return((r=n.value)==null?void 0:r.width)??0}),i=t.computed(()=>{var r;return((r=n.value)==null?void 0:r.height)??0});return t.onMounted(()=>{const r=Gi(e);if(r){n.value={width:r.offsetWidth,height:r.offsetHeight};const s=new ResizeObserver(l=>{if(!Array.isArray(l)||!l.length)return;const d=l[0];let c,_;if("borderBoxSize"in d){const g=d.borderBoxSize,h=Array.isArray(g)?g[0]:g;c=h.inlineSize,_=h.blockSize}else c=r.offsetWidth,_=r.offsetHeight;n.value={width:c,height:_}});return s.observe(r,{box:"border-box"}),()=>s.unobserve(r)}else n.value=void 0}),{width:a,height:i}}function H3(e,n){const a=t.ref(e);function i(s){return n[a.value][s]??a.value}return{state:a,dispatch:s=>{a.value=i(s)}}}function Y3(e,n){var C;const a=t.ref({}),i=t.ref("none"),r=t.ref(e),s=e.value?"mounted":"unmounted";let l;const d=((C=n.value)==null?void 0:C.ownerDocument.defaultView)??Eu,{state:c,dispatch:_}=H3(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}}),g=q=>{var B;if(Cn){const D=new CustomEvent(q,{bubbles:!1,cancelable:!1});(B=n.value)==null||B.dispatchEvent(D)}};t.watch(e,async(q,B)=>{var A;const D=B!==q;if(await t.nextTick(),D){const S=i.value,I=$o(n.value);q?(_("MOUNT"),g("enter"),I==="none"&&g("after-enter")):I==="none"||I==="undefined"||((A=a.value)==null?void 0:A.display)==="none"?(_("UNMOUNT"),g("leave"),g("after-leave")):B&&S!==I?(_("ANIMATION_OUT"),g("leave")):(_("UNMOUNT"),g("after-leave"))}},{immediate:!0});const h=q=>{const B=$o(n.value),D=B.includes(CSS.escape(q.animationName)),A=c.value==="mounted"?"enter":"leave";if(q.target===n.value&&D&&(g(`after-${A}`),_("ANIMATION_END"),!r.value)){const S=n.value.style.animationFillMode;n.value.style.animationFillMode="forwards",l=d==null?void 0:d.setTimeout(()=>{var I;((I=n.value)==null?void 0:I.style.animationFillMode)==="forwards"&&(n.value.style.animationFillMode=S)})}q.target===n.value&&B==="none"&&_("ANIMATION_END")},F=q=>{q.target===n.value&&(i.value=$o(n.value))},p=t.watch(n,(q,B)=>{q?(a.value=getComputedStyle(q),q.addEventListener("animationstart",F),q.addEventListener("animationcancel",h),q.addEventListener("animationend",h)):(_("ANIMATION_END"),l!==void 0&&(d==null||d.clearTimeout(l)),B==null||B.removeEventListener("animationstart",F),B==null||B.removeEventListener("animationcancel",h),B==null||B.removeEventListener("animationend",h))},{immediate:!0}),y=t.watch(c,()=>{const q=$o(n.value);i.value=c.value==="mounted"?q:"none"});return t.onUnmounted(()=>{p(),y()}),{isPresent:t.computed(()=>["mounted","unmountSuspended"].includes(c.value))}}function $o(e){return e&&getComputedStyle(e).animationName||"none"}var Xr=t.defineComponent({name:"Presence",props:{present:{type:Boolean,required:!0},forceMount:{type:Boolean}},slots:{},setup(e,{slots:n,expose:a}){var _;const{present:i,forceMount:r}=t.toRefs(e),s=t.ref(),{isPresent:l}=Y3(i,s);a({present:l});let d=n.default({present:l.value});d=wu(d||[]);const c=t.getCurrentInstance();if(d&&(d==null?void 0:d.length)>1){const g=(_=c==null?void 0:c.parent)!=null&&_.type.name?`<${c.parent.type.name} />`:"component";throw new Error([`Detected an invalid children for \`${g}\` for \`Presence\` component.`,"","Note: Presence works similarly to `v-if` directly, but it waits for animation/transition to finished before unmounting. So it expect only one direct child of valid VNode type.","You can apply a few solutions:",["Provide a single child element so that `presence` directive attach correctly.","Ensure the first child is an actual element instead of a raw text node or comment node."].map(h=>` - ${h}`).join(`
|
|
2
2
|
`)].join(`
|
|
3
3
|
`))}return()=>r.value||i.value||l.value?t.h(n.default({present:l.value})[0],{ref:g=>{const h=Gi(g);return typeof(h==null?void 0:h.hasAttribute)>"u"||(h!=null&&h.hasAttribute("data-reka-popper-content-wrapper")?s.value=h.firstElementChild:s.value=h),h}}):null}});const Su=t.defineComponent({name:"PrimitiveSlot",inheritAttrs:!1,setup(e,{attrs:n,slots:a}){return()=>{var c;if(!a.default)return null;const i=wu(a.default()),r=i.findIndex(_=>_.type!==t.Comment);if(r===-1)return i;const s=i[r];(c=s.props)==null||delete c.ref;const l=s.props?t.mergeProps(n,s.props):n,d=t.cloneVNode({...s,props:{}},l);return i.length===1?d:(i[r]=d,i)}}}),G3=["area","img","input"],Ot=t.defineComponent({name:"Primitive",inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:"div"}},setup(e,{attrs:n,slots:a}){const i=e.asChild?"template":e.as;return typeof i=="string"&&G3.includes(i)?()=>t.h(i,n):i!=="template"?()=>t.h(e.as,n,{default:a.default}):()=>t.h(Su,n,{default:a.default})}});function xf(){const e=t.ref(),n=t.computed(()=>{var a,i;return["#text","#comment"].includes((a=e.value)==null?void 0:a.$el.nodeName)?(i=e.value)==null?void 0:i.$el.nextElementSibling:Gi(e)});return{primitiveElement:e,currentElement:n}}const[ln,W3]=on("DialogRoot");var Q3=t.defineComponent({inheritAttrs:!1,__name:"DialogRoot",props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1,default:!1},modal:{type:Boolean,required:!1,default:!0}},emits:["update:open"],setup(e,{emit:n}){const a=e,r=Qr(a,"open",n,{defaultValue:a.defaultOpen,passive:a.open===void 0}),s=t.ref(),l=t.ref(),{modal:d}=t.toRefs(a);return W3({open:r,modal:d,openModal:()=>{r.value=!0},onOpenChange:c=>{r.value=c},onOpenToggle:()=>{r.value=!r.value},contentId:"",titleId:"",descriptionId:"",triggerElement:s,contentElement:l}),(c,_)=>t.renderSlot(c.$slots,"default",{open:t.unref(r),close:()=>r.value=!1})}}),vf=Q3,X3=t.defineComponent({__name:"DialogClose",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(e){const n=e;nt();const a=ln();return(i,r)=>(t.openBlock(),t.createBlock(t.unref(Ot),t.mergeProps(n,{type:i.as==="button"?"button":void 0,onClick:r[0]||(r[0]=s=>t.unref(a).onOpenChange(!1))}),{default:t.withCtx(()=>[t.renderSlot(i.$slots,"default")]),_:3},16,["type"]))}}),Sf=X3;const K3="dismissableLayer.pointerDownOutside",Z3="dismissableLayer.focusOutside";function jf(e,n){const a=n.closest("[data-dismissable-layer]"),i=e.dataset.dismissableLayer===""?e:e.querySelector("[data-dismissable-layer]"),r=Array.from(e.ownerDocument.querySelectorAll("[data-dismissable-layer]"));return!!(a&&(i===a||r.indexOf(i)<r.indexOf(a)))}function J3(e,n,a=!0){var l;const i=((l=n==null?void 0:n.value)==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),r=t.ref(!1),s=t.ref(()=>{});return t.watchEffect(d=>{if(!Cn||!t.toValue(a))return;const c=async g=>{const h=g.target;if(!(!(n!=null&&n.value)||!h)){if(jf(n.value,h)){r.value=!1;return}if(g.target&&!r.value){let p=function(){bf(K3,e,F)};const F={originalEvent:g};g.pointerType==="touch"?(i.removeEventListener("click",s.value),s.value=p,i.addEventListener("click",s.value,{once:!0})):p()}else i.removeEventListener("click",s.value);r.value=!1}},_=window.setTimeout(()=>{i.addEventListener("pointerdown",c)},0);d(()=>{window.clearTimeout(_),i.removeEventListener("pointerdown",c),i.removeEventListener("click",s.value)})}),{onPointerDownCapture:()=>{t.toValue(a)&&(r.value=!0)}}}function $3(e,n,a=!0){var s;const i=((s=n==null?void 0:n.value)==null?void 0:s.ownerDocument)??(globalThis==null?void 0:globalThis.document),r=t.ref(!1);return t.watchEffect(l=>{if(!Cn||!t.toValue(a))return;const d=async c=>{if(!(n!=null&&n.value))return;await t.nextTick(),await t.nextTick();const _=c.target;!n.value||!_||jf(n.value,_)||c.target&&!r.value&&bf(Z3,e,{originalEvent:c})};i.addEventListener("focusin",d),l(()=>i.removeEventListener("focusin",d))}),{onFocusCapture:()=>{t.toValue(a)&&(r.value=!0)},onBlurCapture:()=>{t.toValue(a)&&(r.value=!1)}}}const En=t.reactive({layersRoot:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set});var e4=t.defineComponent({__name:"DismissableLayer",props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","dismiss"],setup(e,{emit:n}){const a=e,i=n,{forwardRef:r,currentElement:s}=nt(),l=t.computed(()=>{var y;return((y=s.value)==null?void 0:y.ownerDocument)??globalThis.document}),d=t.computed(()=>En.layersRoot),c=t.computed(()=>s.value?Array.from(d.value).indexOf(s.value):-1),_=t.computed(()=>En.layersWithOutsidePointerEventsDisabled.size>0),g=t.computed(()=>{const y=Array.from(d.value),[w]=[...En.layersWithOutsidePointerEventsDisabled].slice(-1),C=y.indexOf(w);return c.value>=C}),h=J3(async y=>{const w=[...En.branches].some(C=>C==null?void 0:C.contains(y.target));!g.value||w||(i("pointerDownOutside",y),i("interactOutside",y),await t.nextTick(),y.defaultPrevented||i("dismiss"))},s),F=$3(y=>{[...En.branches].some(C=>C==null?void 0:C.contains(y.target))||(i("focusOutside",y),i("interactOutside",y),y.defaultPrevented||i("dismiss"))},s);C3("Escape",y=>{c.value===d.value.size-1&&(i("escapeKeyDown",y),y.defaultPrevented||i("dismiss"))});let p;return t.watchEffect(y=>{s.value&&(a.disableOutsidePointerEvents&&(En.layersWithOutsidePointerEventsDisabled.size===0&&(p=l.value.body.style.pointerEvents,l.value.body.style.pointerEvents="none"),En.layersWithOutsidePointerEventsDisabled.add(s.value)),d.value.add(s.value),y(()=>{a.disableOutsidePointerEvents&&En.layersWithOutsidePointerEventsDisabled.size===1&&(l.value.body.style.pointerEvents=p)}))}),t.watchEffect(y=>{y(()=>{s.value&&(d.value.delete(s.value),En.layersWithOutsidePointerEventsDisabled.delete(s.value))})}),(y,w)=>(t.openBlock(),t.createBlock(t.unref(Ot),{ref:t.unref(r),"as-child":y.asChild,as:y.as,"data-dismissable-layer":"",style:t.normalizeStyle({pointerEvents:_.value?g.value?"auto":"none":void 0}),onFocusCapture:t.unref(F).onFocusCapture,onBlurCapture:t.unref(F).onBlurCapture,onPointerdownCapture:t.unref(h).onPointerDownCapture},{default:t.withCtx(()=>[t.renderSlot(y.$slots,"default")]),_:3},8,["as-child","as","style","onFocusCapture","onBlurCapture","onPointerdownCapture"]))}}),ju=e4;const t4=u3(()=>t.ref([]));function a4(){const e=t4();return{add(n){const a=e.value[0];n!==a&&(a==null||a.pause()),e.value=qf(e.value,n),e.value.unshift(n)},remove(n){var a;e.value=qf(e.value,n),(a=e.value[0])==null||a.resume()}}}function qf(e,n){const a=[...e],i=a.indexOf(n);return i!==-1&&a.splice(i,1),a}function n4(e){return e.filter(n=>n.tagName!=="A")}const qu="focusScope.autoFocusOnMount",Iu="focusScope.autoFocusOnUnmount",If={bubbles:!1,cancelable:!0};function i4(e,{select:n=!1}={}){const a=sn();for(const i of e)if(ei(i,{select:n}),sn()!==a)return!0}function r4(e){const n=Nf(e),a=Tf(n,e),i=Tf(n.reverse(),e);return[a,i]}function Nf(e){const n=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)n.push(a.currentNode);return n}function Tf(e,n){for(const a of e)if(!o4(a,{upTo:n}))return a}function o4(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function s4(e){return e instanceof HTMLInputElement&&"select"in e}function ei(e,{select:n=!1}={}){if(e&&e.focus){const a=sn();e.focus({preventScroll:!0}),e!==a&&s4(e)&&n&&e.select()}}var l4=t.defineComponent({__name:"FocusScope",props:{loop:{type:Boolean,required:!1,default:!1},trapped:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["mountAutoFocus","unmountAutoFocus"],setup(e,{emit:n}){const a=e,i=n,{currentRef:r,currentElement:s}=nt(),l=t.ref(null),d=a4(),c=t.reactive({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}});t.watchEffect(g=>{if(!Cn)return;const h=s.value;if(!a.trapped)return;function F(C){if(c.paused||!h)return;const q=C.target;h.contains(q)?l.value=q:ei(l.value,{select:!0})}function p(C){if(c.paused||!h)return;const q=C.relatedTarget;q!==null&&(h.contains(q)||ei(l.value,{select:!0}))}function y(C){h.contains(l.value)||ei(h)}document.addEventListener("focusin",F),document.addEventListener("focusout",p);const w=new MutationObserver(y);h&&w.observe(h,{childList:!0,subtree:!0}),g(()=>{document.removeEventListener("focusin",F),document.removeEventListener("focusout",p),w.disconnect()})}),t.watchEffect(async g=>{const h=s.value;if(await t.nextTick(),!h)return;d.add(c);const F=sn();if(!h.contains(F)){const y=new CustomEvent(qu,If);h.addEventListener(qu,w=>i("mountAutoFocus",w)),h.dispatchEvent(y),y.defaultPrevented||(i4(n4(Nf(h)),{select:!0}),sn()===F&&ei(h))}g(()=>{h.removeEventListener(qu,C=>i("mountAutoFocus",C));const y=new CustomEvent(Iu,If),w=C=>{i("unmountAutoFocus",C)};h.addEventListener(Iu,w),h.dispatchEvent(y),setTimeout(()=>{y.defaultPrevented||ei(F??document.body,{select:!0}),h.removeEventListener(Iu,w),d.remove(c)},0)})});function _(g){if(!a.loop&&!a.trapped||c.paused)return;const h=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,F=sn();if(h&&F){const p=g.currentTarget,[y,w]=r4(p);y&&w?!g.shiftKey&&F===w?(g.preventDefault(),a.loop&&ei(y,{select:!0})):g.shiftKey&&F===y&&(g.preventDefault(),a.loop&&ei(w,{select:!0})):F===p&&g.preventDefault()}}return(g,h)=>(t.openBlock(),t.createBlock(t.unref(Ot),{ref_key:"currentRef",ref:r,tabindex:"-1","as-child":g.asChild,as:g.as,onKeydown:_},{default:t.withCtx(()=>[t.renderSlot(g.$slots,"default")]),_:3},8,["as-child","as"]))}}),Of=l4;function u4(e){return e?"open":"closed"}const d4="DialogTitle",c4="DialogContent";function f4({titleName:e=d4,contentName:n=c4,componentLink:a="dialog.html#title",titleId:i,descriptionId:r,contentElement:s}){const l=`Warning: \`${n}\` requires a \`${e}\` for the component to be accessible for screen reader users.
|
|
4
4
|
|
package/package.json
CHANGED
package/src/utils/sanitize.js
CHANGED
|
@@ -12,17 +12,11 @@ export function escapeHtml(input) {
|
|
|
12
12
|
* Sanitizes HTML by removing disallowed tags and unsafe attributes.
|
|
13
13
|
* @param {string} input
|
|
14
14
|
* @param {Array<string>} allowedTags - List of allowed HTML tags.
|
|
15
|
-
* @param {number} maxLength - Maximum length of the sanitized string.
|
|
16
15
|
* @returns {string}
|
|
17
16
|
*/
|
|
18
|
-
export function sanitizeHtml(input, allowedTags = []
|
|
17
|
+
export function sanitizeHtml(input, allowedTags = []) {
|
|
19
18
|
if (typeof input !== 'string') return '';
|
|
20
19
|
|
|
21
|
-
// Limits text length
|
|
22
|
-
if (input.length > maxLength) {
|
|
23
|
-
input = input.substring(0, maxLength);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
20
|
// Decodes HTML entities (<, >, &)
|
|
27
21
|
input = escapeHtml(input);
|
|
28
22
|
|
|
@@ -41,13 +35,12 @@ export function sanitizeHtml(input, allowedTags = [], maxLength = 1000) {
|
|
|
41
35
|
*
|
|
42
36
|
* @param {string} input
|
|
43
37
|
* @param {Array<string>} allowedTags - List of allowed HTML tags.
|
|
44
|
-
* @param {number} maxLength - Maximum length of the sanitized string.
|
|
45
38
|
* @returns {string}
|
|
46
39
|
*/
|
|
47
|
-
export function fullySanitize(input, allowedTags = []
|
|
40
|
+
export function fullySanitize(input, allowedTags = []) {
|
|
48
41
|
if (typeof input !== 'string') return '';
|
|
49
42
|
|
|
50
|
-
let sanitizedInput = sanitizeHtml(input, allowedTags
|
|
43
|
+
let sanitizedInput = sanitizeHtml(input, allowedTags);
|
|
51
44
|
|
|
52
45
|
return escapeHtml(sanitizedInput);
|
|
53
46
|
}
|
|
@@ -56,10 +49,9 @@ export function fullySanitize(input, allowedTags = [], maxLength = 1000) {
|
|
|
56
49
|
* Validates and sanitizes input text.
|
|
57
50
|
* @param {string} input - The input string to validate.
|
|
58
51
|
* @param {Array<string>} allowedTags - List of allowed HTML tags.
|
|
59
|
-
* @param {number} maxLength - Maximum length of the sanitized string.
|
|
60
52
|
* @returns {{ isValid: boolean, sanitized: string, errors: string[] }} - Validation result.
|
|
61
53
|
*/
|
|
62
|
-
export function validateInput(input, allowedTags = []
|
|
54
|
+
export function validateInput(input, allowedTags = []) {
|
|
63
55
|
const errors = [];
|
|
64
56
|
|
|
65
57
|
if (typeof input !== 'string') {
|
|
@@ -67,12 +59,7 @@ export function validateInput(input, allowedTags = [], maxLength = 1000) {
|
|
|
67
59
|
return { isValid: false, sanitized: '', errors };
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
errors.push(`Input exceeds the maximum length of ${maxLength} characters.`);
|
|
72
|
-
input = input.substring(0, maxLength);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const sanitized = fullySanitize(input, allowedTags, maxLength);
|
|
62
|
+
const sanitized = fullySanitize(input, allowedTags);
|
|
76
63
|
|
|
77
64
|
if (sanitized !== input) {
|
|
78
65
|
errors.push(
|