@dropins/tools 0.31.0-alpha004 → 0.31.0-alpha007
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/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as v}from"./chunks/is-number.js";import{R as
|
|
1
|
+
import{d as M,S as v}from"./chunks/is-number.js";import{R as Y,V as Z,c as x,a as ee,g as re,i as te}from"./chunks/is-number.js";import{C as oe,I as se,i as ie}from"./chunks/initializer.js";import{jsx as E}from"./preact-jsx-runtime.js";import{x as O,A as b,h as P,T as $,E as _,q as p,y as D}from"./chunks/icons/Add.js";import{IntlContext as V}from"./i18n.js";import{g as de,s as ae}from"./chunks/image-params-keymap.js";import"./signals.js";const k=r=>{const n=new FormData(r);return Object.fromEntries(n)},A=r=>{const n=new FormData(r),l=Object.fromEntries(n);return Object.entries(l).reduce((s,[d])=>{const o=r.elements[d];return o!=null&&o.validationMessage?{...s,[d]:o.validationMessage}:{...s}},{})},F={arrayMerge:(r,n,l)=>{const u=r.slice();return n.forEach((s,d)=>{typeof u[d]>"u"?u[d]=l.cloneUnlessOtherwiseSpecified(s,l):l.isMergeableObject(s)?u[d]=M(r[d],s,l):r.indexOf(s)===-1&&u.push(s)}),u}};function U(r,n){return n?M(r,n,F):r}const W=r=>r.replace("_","-");function T(r,n={},l,u,s){const d=O(v),o=b(null),S=b("pending"),w=b([]),[y,R]=P({children:[u]}),[N,j]=P({}),I=$(()=>({get:t=>N[t],set:(t,e)=>{j({...I,[t]:e})}}),[N]),{intl:B}=O(V);n.dictionary=B.dictionary,n._setProps=t=>{R(e=>{const i=typeof t=="function"?t(e):t;if(s){const a=_(s(e),{key:"render"}),f=e.children.findIndex(g=>(g==null?void 0:g.key)==="render");e.children[f]=a}return i})};const c=p(t=>{typeof t=="function"?w.current.push(t):console.warn("Skipped: Invalid _registerMethod",t)},[]);n._registerMethod=c;const h=p(t=>E("div",{"data-slot-html-element":t.tagName.toLowerCase(),ref:e=>{e==null||e.appendChild(t)}}),[]);n._htmlElementToVNode=h,n.getSlotElement=p(t=>{var i,a;const e=(i=o.current)==null?void 0:i.querySelector(`[data-slot-key="${t}"]`);if(m(`🟦 "${r}" Slot getSlotElement: ${t}`,(a=o.current)==null?void 0:a.cloneNode(!0),e==null?void 0:e.cloneNode(!0)),!!e)return{appendChild:f=>{e.appendChild(f)},prependChild:f=>{e.insertBefore(f,e.firstChild)},appendSibling:f=>{const g=e.parentNode;g==null||g.insertBefore(f,e.nextSibling)},prependSibling:f=>{const g=e.parentNode;g==null||g.insertBefore(f,e)}}},[r]),n.onRender=p(t=>{w.current.push(t)},[]),n.onChange=n.onRender,n.replaceWith=p(t=>{c(e=>{const i=h(t);e._setProps({children:[i]})})},[h,c]),n.appendChild=p(t=>{c(e=>{const i=h(t);e._setProps(a=>({...a,children:[...a.children,i]}))})},[h,c]),n.prependChild=p(t=>{c(e=>{const i=h(t);e._setProps(a=>({...a,children:[i,...a.children]}))})},[h,c]),n.appendSibling=p(t=>{c(()=>{var i,a;const e=(i=o.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,((a=o.current)==null?void 0:a.nextSibling)??null)})},[c]),n.prependSibling=p(t=>{c(()=>{var i;const e=(i=o.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,o.current)})},[c]);const C=p(async()=>{if(S.current==="loading")return;S.current="loading",m(`🟨 "${r}" Slot Rendered`);const t=s?_(s(y),{key:"render"}):null;R({children:[t??u]}),w.current.forEach(e=>{e(n,I)}),S.current="ready"},[u,n,r,y,s,I]),L=p(async()=>{if(l)try{S.current="loading",m(`🟩 "${r}" Slot Initialized`),await l(n,o.current)}catch(t){console.error(`Error in "${l.name}" Slot callback`,t)}finally{S.current="ready",await C()}},[l,n,C,r]);return D(()=>{L().finally(()=>{d&&(d.value.delete(r),d.value=new Set(d.value))})},[]),D(()=>{C()},[JSON.stringify(n),JSON.stringify(N)]),[o,y]}function G({name:r,context:n,slot:l,children:u,render:s,...d}){const o=O(v),[S,w]=T(r,n,l,u,s);return $(()=>{if(!r)return console.warn('Slot "name" is required');o&&(o.value.add(r),o.value=new Set(o.value))},[r,o]),E("div",{...d,ref:S,"data-slot":r,children:w.children})}window.DROPINS=window.DROPINS||{};window.DROPINS.showSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--show-slots",r.toString()),document.body.classList.toggle("dropin-debugger--show-slots",r)};let m=()=>{};window.DROPINS.logSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--log-slots",r.toString()),m=r?(...n)=>console.log(...n):()=>{}};window.DROPINS.showSlots(window.sessionStorage.getItem("dropin-debugger--show-slots")==="true");window.DROPINS.logSlots(window.sessionStorage.getItem("dropin-debugger--log-slots")==="true");export{oe as Config,se as Initializer,Y as Render,G as Slot,v as SlotQueueContext,Z as VComponent,x as classes,ee as debounce,M as deepmerge,re as generateSrcset,A as getFormErrors,k as getFormValues,de as getImageParamsKeyMap,ie as initializers,te as isNumber,U as merge,ae as setImageParamsKeyMap,W as toLanguageTag,T as useSlot};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/tools", "version": "0.31.0-
|
|
1
|
+
{"name": "@dropins/tools", "version": "0.31.0-alpha007"}
|