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