@ramstack/alpinegear-main 1.0.0 → 1.1.0-preview.2
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/alpinegear-main.esm.js +12 -12
- package/alpinegear-main.esm.min.js +1 -1
- package/alpinegear-main.js +12 -12
- package/alpinegear-main.min.js +1 -1
- package/package.json +1 -1
package/alpinegear-main.esm.js
CHANGED
|
@@ -104,7 +104,7 @@ const create_map = keys => new Map(
|
|
|
104
104
|
keys.split(",").map(v => [v.trim().toLowerCase(), v.trim()]));
|
|
105
105
|
|
|
106
106
|
function watch(get_value, callback, options = null) {
|
|
107
|
-
assert(Alpine, "Alpine is not defined
|
|
107
|
+
assert(Alpine, "Alpine is not defined");
|
|
108
108
|
|
|
109
109
|
const {
|
|
110
110
|
effect,
|
|
@@ -158,7 +158,7 @@ function plugin$5({ directive, entangle, evaluateLater, mapAttributes, mutateDom
|
|
|
158
158
|
|
|
159
159
|
directive("bound", (el, { expression, value, modifiers }, { effect, cleanup }) => {
|
|
160
160
|
if (!value) {
|
|
161
|
-
warn("x-bound directive expects the presence of a bound property name
|
|
161
|
+
warn("x-bound directive expects the presence of a bound property name");
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -238,12 +238,12 @@ function plugin$5({ directive, entangle, evaluateLater, mapAttributes, mutateDom
|
|
|
238
238
|
: el;
|
|
239
239
|
|
|
240
240
|
if (!el._x_dataStack) {
|
|
241
|
-
warn("x-bound directive requires the presence of the x-data directive to bind component properties
|
|
241
|
+
warn("x-bound directive requires the presence of the x-data directive to bind component properties");
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
if (!source_el) {
|
|
246
|
-
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined
|
|
246
|
+
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined`);
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -554,7 +554,7 @@ function initialize() {
|
|
|
554
554
|
function plugin$3({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
555
555
|
directive("fragment", (el, {}, { cleanup }) => {
|
|
556
556
|
if (!is_template(el)) {
|
|
557
|
-
warn("x-fragment can only be used on a 'template' tag
|
|
557
|
+
warn("x-fragment can only be used on a 'template' tag");
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
560
|
|
|
@@ -565,7 +565,7 @@ function plugin$3({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
|
565
565
|
function plugin$2({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
566
566
|
directive("match", (el, { }, { cleanup, effect, evaluateLater }) => {
|
|
567
567
|
if (!is_template(el)) {
|
|
568
|
-
warn("x-match can only be used on a 'template' tag
|
|
568
|
+
warn("x-match can only be used on a 'template' tag");
|
|
569
569
|
return;
|
|
570
570
|
}
|
|
571
571
|
|
|
@@ -575,15 +575,15 @@ function plugin$2({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
|
575
575
|
for (let node of el.content.children) {
|
|
576
576
|
const expr = node.getAttribute("x-case");
|
|
577
577
|
if (expr !== null) {
|
|
578
|
-
has_default_case() && warn("The x-case directive cannot be appear after x-default
|
|
578
|
+
has_default_case() && warn("The x-case directive cannot be appear after x-default");
|
|
579
579
|
branches.push({ el: node, get_value: create_getter(evaluateLater, expr) });
|
|
580
580
|
}
|
|
581
581
|
else if (node.hasAttribute("x-default")) {
|
|
582
|
-
has_default_case() && warn("Only one x-default directive is allowed
|
|
582
|
+
has_default_case() && warn("Only one x-default directive is allowed");
|
|
583
583
|
branches.push({ el: node, get_value: () => true, default: true });
|
|
584
584
|
}
|
|
585
585
|
else {
|
|
586
|
-
warn("Element has no x-case or x-default directive and will be ignored
|
|
586
|
+
warn("Element has no x-case or x-default directive and will be ignored", node);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
|
|
@@ -618,14 +618,14 @@ function plugin$2({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
|
618
618
|
function plugin$1(alpine) {
|
|
619
619
|
alpine.directive("template", (el, { expression }) => {
|
|
620
620
|
if (is_template(el)) {
|
|
621
|
-
warn("x-template cannot be used on a 'template' tag
|
|
621
|
+
warn("x-template cannot be used on a 'template' tag");
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
const tpl = document.getElementById(expression);
|
|
626
626
|
|
|
627
627
|
if (!is_template(tpl)) {
|
|
628
|
-
warn("x-template directive can only reference the template tag
|
|
628
|
+
warn("x-template directive can only reference the template tag");
|
|
629
629
|
return;
|
|
630
630
|
}
|
|
631
631
|
|
|
@@ -644,7 +644,7 @@ function plugin$1(alpine) {
|
|
|
644
644
|
function plugin({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
645
645
|
directive("when", (el, { expression }, { cleanup, effect, evaluateLater }) => {
|
|
646
646
|
if (!is_template(el)) {
|
|
647
|
-
warn("x-when can only be used on a 'template' tag
|
|
647
|
+
warn("x-when can only be used on a 'template' tag");
|
|
648
648
|
return;
|
|
649
649
|
}
|
|
650
650
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,...t){const n=e(...t);return()=>{let e;return n((t=>e=t)),t=e,"function"==typeof t?.get?e.get():e;var t}}function t(e,...t){const n=e(...t);t[t.length-1]=`${t.at(-1)} = __val`;const o=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):o((()=>{}),{scope:{__val:e}})}}const n=Symbol();let o;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,c=e=>null==e,i=e=>"checkbox"===e.type||"radio"===e.type,l=e=>e instanceof HTMLTemplateElement,u=e=>e.nodeType===Node.ELEMENT_NODE,s=e=>r(e)?e:[e],d=(e,t)=>e==t,f=(e,t)=>e.findIndex((e=>e==t)),p=(e,t)=>e.includes(t),m=(e,t,n,o)=>(e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)),v=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function h(e,t,n=null){const{effect:o,release:a}=Alpine;let r,c,i=!1;const l=o((()=>{r=e(),i||(n?.deep&&JSON.stringify(r),c=r),(i||(n?.immediate??1))&&setTimeout((()=>{t(r,c),c=r}),0),i=!0}));return()=>a(l)}const b=new Map("value,checked,files,innerHTML,innerText,textContent,videoHeight,videoWidth,naturalHeight,naturalWidth,clientHeight,clientWidth,offsetHeight,offsetWidth,open,group".split(",").map((e=>[e.trim().toLowerCase(),e.trim()])));function g({directive:l,entangle:u,evaluateLater:g,mapAttributes:T,mutateDom:_,prefixed:k}){T((e=>({name:e.name.replace(/^&/,k("bound:")),value:e.value}))),l("bound",((l,{expression:T,value:k,modifiers:x},{effect:N,cleanup:y})=>{if(!k)return void a("x-bound directive expects the presence of a bound property name
|
|
1
|
+
function e(e,...t){const n=e(...t);return()=>{let e;return n((t=>e=t)),t=e,"function"==typeof t?.get?e.get():e;var t}}function t(e,...t){const n=e(...t);t[t.length-1]=`${t.at(-1)} = __val`;const o=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):o((()=>{}),{scope:{__val:e}})}}const n=Symbol();let o;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,c=e=>null==e,i=e=>"checkbox"===e.type||"radio"===e.type,l=e=>e instanceof HTMLTemplateElement,u=e=>e.nodeType===Node.ELEMENT_NODE,s=e=>r(e)?e:[e],d=(e,t)=>e==t,f=(e,t)=>e.findIndex((e=>e==t)),p=(e,t)=>e.includes(t),m=(e,t,n,o)=>(e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)),v=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function h(e,t,n=null){const{effect:o,release:a}=Alpine;let r,c,i=!1;const l=o((()=>{r=e(),i||(n?.deep&&JSON.stringify(r),c=r),(i||(n?.immediate??1))&&setTimeout((()=>{t(r,c),c=r}),0),i=!0}));return()=>a(l)}const b=new Map("value,checked,files,innerHTML,innerText,textContent,videoHeight,videoWidth,naturalHeight,naturalWidth,clientHeight,clientWidth,offsetHeight,offsetWidth,open,group".split(",").map((e=>[e.trim().toLowerCase(),e.trim()])));function g({directive:l,entangle:u,evaluateLater:g,mapAttributes:T,mutateDom:_,prefixed:k}){T((e=>({name:e.name.replace(/^&/,k("bound:")),value:e.value}))),l("bound",((l,{expression:T,value:k,modifiers:x},{effect:N,cleanup:y})=>{if(!k)return void a("x-bound directive expects the presence of a bound property name");const E=l.tagName.toUpperCase();T=T?.trim();const w=b.get(k.trim().replace("-","").toLowerCase());T||=w;const L=e(g,l,T),S=t(g,l,T),D=()=>d(l[w],L())||_((()=>l[w]=L())),H=()=>S((e=>"number"===e.type||"range"===e.type)(l)?function(e){return""===e?null:+e}(l[w]):l[w]);let M;switch(w){case"value":!function(){switch(E){case"INPUT":case"TEXTAREA":c(L())&&H(),N(D),y(m(l,"input",H)),M=!0;break;case"SELECT":queueMicrotask((()=>{c(L())&&H(),N((()=>function(e,t){for(const n of e.options)n.selected=f(t,n.value)>=0}(l,s(L()??[])))),y(m(l,"change",(()=>S(function(e){return e.multiple?[...e.selectedOptions].map((e=>e.value)):e.value}(l)))))})),M=!0}}();break;case"checked":i(l)&&(N(D),y(m(l,"change",H)),M=!0);break;case"files":"file"===l.type&&(y(m(l,"input",H)),M=!0);break;case"innerHTML":case"innerText":case"textContent":"true"===l.contentEditable&&(c(L())&&H(),N(D),y(m(l,"input",H)),M=!0);break;case"videoHeight":case"videoWidth":A("VIDEO","resize");break;case"naturalHeight":case"naturalWidth":A("IMG","load");break;case"clientHeight":case"clientWidth":case"offsetHeight":case"offsetWidth":y(function(e,t){return o??=new ResizeObserver((e=>{for(const t of e)for(const e of t.target[n]?.values()??[])e(t)})),e[n]??=new Set,e[n].add(t),o.observe(e),()=>{e[n].delete(t),e[n].size||(o.unobserve(e),e[n]=null)}}(l,H)),M=!0;break;case"open":"DETAILS"===E&&(c(L())&&H(),N(D),y(m(l,"toggle",H)),M=!0);break;case"group":i(l)&&(l.name||_((()=>l.name=T)),N((()=>_((()=>function(e,t){e.checked=r(t)?f(t,e.value)>=0:d(e.value,t)}(l,L()??[]))))),y(m(l,"input",(()=>S(function(e,t){if("radio"===e.type)return e.value;t=s(t);const n=f(t,e.value);return e.checked?n>=0||t.push(e.value):n>=0&&t.splice(n,1),t}(l,L()))))),M=!0)}if(!M){const n=p(x,"in")?"in":p(x,"out")?"out":"inout",o=T===k?(e=>{for(;e&&!e._x_dataStack;)e=(e._x_teleportBack??e).parentElement;return e})(l.parentNode):l;if(!l._x_dataStack)return void a("x-bound directive requires the presence of the x-data directive to bind component properties");if(!o)return void a(`x-bound directive cannot find the parent scope where the '${k}' property is defined`);const r={get:e(g,o,T),set:t(g,o,T)},c={get:e(g,l,k),set:t(g,l,k)};switch(n){case"in":y(h((()=>r.get()),(e=>c.set(v(e)))));break;case"out":y(h((()=>c.get()),(e=>r.set(v(e)))));break;default:y(u(r,c))}}function A(e,t){E===e&&(H(),y(m(l,t,H)),M=!0)}}))}function T({directive:t,mutateDom:n}){t("format",((t,{modifiers:o},{effect:a,evaluateLater:r})=>{const i=new Map,l=/{{(?<expr>.+?)}}/g,u=p(o,"once");function s(t){let n=i.get(t);return c(n)&&(n=e(r,t),i.set(t,n)),n}function d(e){u?(n((()=>e())),i.clear()):a((()=>n((()=>e()))))}!function e(t){switch(t.nodeType){case Node.TEXT_NODE:!function(e){const t=e.textContent.split(l);if(t.length>1){const o=new DocumentFragment;for(let e=0;t.length>e;e++)if(e%2==0)o.appendChild(document.createTextNode(t[e]));else{const n=s(t[e]),a=document.createTextNode("");o.append(a),d((()=>a.textContent=n()))}n((()=>e.parentElement.replaceChild(o,e)))}}(t);break;case Node.ELEMENT_NODE:!function(t){for(let n of t.childNodes)e(n)}(t),function(e){for(let t of e.attributes)if([...t.value.matchAll(l)].length){const e=t.value;d((()=>t.value=e.replace(l,((e,t)=>s(t)()))))}}(t)}}(t)}))}function _(e,t,{addScopeToNode:n,cleanup:o,initTree:a,mutateDom:r,scope:c={}}){if(e._r_block)return;document.body._r_block??=(()=>{const e=new MutationObserver((e=>{for(let t of e)for(let e of t.addedNodes)e._r_block?.update()}));return e.observe(document.body,{childList:!0,subtree:!0}),e})();let i=l(t)?[...t.content.cloneNode(!0).childNodes]:[t.cloneNode(!0)];r((()=>{for(let t of i)u(t)&&n(t,c,e),e.parentElement.insertBefore(t,e),u(t)&&a(t)})),e._r_block={template:t,update(){r((()=>{for(let t of i??[])e.parentElement.insertBefore(t,e)}))},delete(){e._r_block=null;for(let e of i??[])e.remove();i=null}},o((()=>e._r_block?.delete()))}function k({addScopeToNode:e,directive:t,initTree:n,mutateDom:o}){t("fragment",((t,{},{cleanup:r})=>{l(t)?_(t,t,{addScopeToNode:e,cleanup:r,initTree:n,mutateDom:o}):a("x-fragment can only be used on a 'template' tag")}))}function x({addScopeToNode:t,directive:n,initTree:o,mutateDom:r}){n("match",((n,{},{cleanup:c,effect:i,evaluateLater:u})=>{if(!l(n))return void a("x-match can only be used on a 'template' tag");const s=[];for(let t of n.content.children){const n=t.getAttribute("x-case");null!==n?s.push({el:t,get_value:e(u,n)}):t.hasAttribute("x-default")&&s.push({el:t,get_value:()=>!0,default:!0})}const d=()=>n._r_block?.delete();i((()=>{let e;for(let t of s)t.get_value()&&!e&&(e=t);var a;e?(a=e,n._r_block?.template!==a.el&&(d(),_(n,a.el,{addScopeToNode:t,cleanup:c,initTree:o,mutateDom:r}))):d()}))}))}function N(e){e.directive("template",((e,{expression:t})=>{if(l(e))return void a("x-template cannot be used on a 'template' tag");const n=document.getElementById(t);l(n)?queueMicrotask((()=>{e.innerHTML="",e.append(n.content.cloneNode(!0))})):a("x-template directive can only reference the template tag")}))}function y({addScopeToNode:t,directive:n,initTree:o,mutateDom:r}){n("when",((n,{expression:c},{cleanup:i,effect:u,evaluateLater:s})=>{if(!l(n))return void a("x-when can only be used on a 'template' tag");const d=e(s,c);u((()=>d()?_(n,n,{addScopeToNode:t,cleanup:i,initTree:o,mutateDom:r}):n._r_block?.delete()))}))}export{g as bound,T as format,k as fragment,x as match,N as template,y as when};
|
package/alpinegear-main.js
CHANGED
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
keys.split(",").map(v => [v.trim().toLowerCase(), v.trim()]));
|
|
108
108
|
|
|
109
109
|
function watch(get_value, callback, options = null) {
|
|
110
|
-
assert(Alpine, "Alpine is not defined
|
|
110
|
+
assert(Alpine, "Alpine is not defined");
|
|
111
111
|
|
|
112
112
|
const {
|
|
113
113
|
effect,
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
|
|
162
162
|
directive("bound", (el, { expression, value, modifiers }, { effect, cleanup }) => {
|
|
163
163
|
if (!value) {
|
|
164
|
-
warn("x-bound directive expects the presence of a bound property name
|
|
164
|
+
warn("x-bound directive expects the presence of a bound property name");
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -241,12 +241,12 @@
|
|
|
241
241
|
: el;
|
|
242
242
|
|
|
243
243
|
if (!el._x_dataStack) {
|
|
244
|
-
warn("x-bound directive requires the presence of the x-data directive to bind component properties
|
|
244
|
+
warn("x-bound directive requires the presence of the x-data directive to bind component properties");
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
if (!source_el) {
|
|
249
|
-
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined
|
|
249
|
+
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined`);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -557,7 +557,7 @@
|
|
|
557
557
|
function plugin$3({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
558
558
|
directive("fragment", (el, {}, { cleanup }) => {
|
|
559
559
|
if (!is_template(el)) {
|
|
560
|
-
warn("x-fragment can only be used on a 'template' tag
|
|
560
|
+
warn("x-fragment can only be used on a 'template' tag");
|
|
561
561
|
return;
|
|
562
562
|
}
|
|
563
563
|
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
function plugin$2({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
569
569
|
directive("match", (el, { }, { cleanup, effect, evaluateLater }) => {
|
|
570
570
|
if (!is_template(el)) {
|
|
571
|
-
warn("x-match can only be used on a 'template' tag
|
|
571
|
+
warn("x-match can only be used on a 'template' tag");
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
574
|
|
|
@@ -578,15 +578,15 @@
|
|
|
578
578
|
for (let node of el.content.children) {
|
|
579
579
|
const expr = node.getAttribute("x-case");
|
|
580
580
|
if (expr !== null) {
|
|
581
|
-
has_default_case() && warn("The x-case directive cannot be appear after x-default
|
|
581
|
+
has_default_case() && warn("The x-case directive cannot be appear after x-default");
|
|
582
582
|
branches.push({ el: node, get_value: create_getter(evaluateLater, expr) });
|
|
583
583
|
}
|
|
584
584
|
else if (node.hasAttribute("x-default")) {
|
|
585
|
-
has_default_case() && warn("Only one x-default directive is allowed
|
|
585
|
+
has_default_case() && warn("Only one x-default directive is allowed");
|
|
586
586
|
branches.push({ el: node, get_value: () => true, default: true });
|
|
587
587
|
}
|
|
588
588
|
else {
|
|
589
|
-
warn("Element has no x-case or x-default directive and will be ignored
|
|
589
|
+
warn("Element has no x-case or x-default directive and will be ignored", node);
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
|
|
@@ -621,14 +621,14 @@
|
|
|
621
621
|
function plugin$1(alpine) {
|
|
622
622
|
alpine.directive("template", (el, { expression }) => {
|
|
623
623
|
if (is_template(el)) {
|
|
624
|
-
warn("x-template cannot be used on a 'template' tag
|
|
624
|
+
warn("x-template cannot be used on a 'template' tag");
|
|
625
625
|
return;
|
|
626
626
|
}
|
|
627
627
|
|
|
628
628
|
const tpl = document.getElementById(expression);
|
|
629
629
|
|
|
630
630
|
if (!is_template(tpl)) {
|
|
631
|
-
warn("x-template directive can only reference the template tag
|
|
631
|
+
warn("x-template directive can only reference the template tag");
|
|
632
632
|
return;
|
|
633
633
|
}
|
|
634
634
|
|
|
@@ -647,7 +647,7 @@
|
|
|
647
647
|
function plugin({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
648
648
|
directive("when", (el, { expression }, { cleanup, effect, evaluateLater }) => {
|
|
649
649
|
if (!is_template(el)) {
|
|
650
|
-
warn("x-when can only be used on a 'template' tag
|
|
650
|
+
warn("x-when can only be used on a 'template' tag");
|
|
651
651
|
return;
|
|
652
652
|
}
|
|
653
653
|
|
package/alpinegear-main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,...t){const n=e(...t);return()=>{let e;return n((t=>e=t)),t=e,"function"==typeof t?.get?e.get():e;var t}}function t(e,...t){const n=e(...t);t[t.length-1]=`${t.at(-1)} = __val`;const o=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):o((()=>{}),{scope:{__val:e}})}}const n=Symbol();let o;const a=(...e)=>console.warn("alpine-gear.js:",...e),c=Array.isArray,r=e=>null==e,i=e=>"checkbox"===e.type||"radio"===e.type,l=e=>e instanceof HTMLTemplateElement,u=e=>e.nodeType===Node.ELEMENT_NODE,s=e=>c(e)?e:[e],d=(e,t)=>e==t,f=(e,t)=>e.findIndex((e=>e==t)),p=(e,t)=>e.includes(t),m=(e,t,n,o)=>(e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)),v=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function h(e,t,n=null){const{effect:o,release:a}=Alpine;let c,r,i=!1;const l=o((()=>{c=e(),i||(n?.deep&&JSON.stringify(c),r=c),(i||(n?.immediate??1))&&setTimeout((()=>{t(c,r),r=c}),0),i=!0}));return()=>a(l)}const b=new Map("value,checked,files,innerHTML,innerText,textContent,videoHeight,videoWidth,naturalHeight,naturalWidth,clientHeight,clientWidth,offsetHeight,offsetWidth,open,group".split(",").map((e=>[e.trim().toLowerCase(),e.trim()])));function g(e,t,{addScopeToNode:n,cleanup:o,initTree:a,mutateDom:c,scope:r={}}){if(e._r_block)return;document.body._r_block??=(()=>{const e=new MutationObserver((e=>{for(let t of e)for(let e of t.addedNodes)e._r_block?.update()}));return e.observe(document.body,{childList:!0,subtree:!0}),e})();let i=l(t)?[...t.content.cloneNode(!0).childNodes]:[t.cloneNode(!0)];c((()=>{for(let t of i)u(t)&&n(t,r,e),e.parentElement.insertBefore(t,e),u(t)&&a(t)})),e._r_block={template:t,update(){c((()=>{for(let t of i??[])e.parentElement.insertBefore(t,e)}))},delete(){e._r_block=null;for(let e of i??[])e.remove();i=null}},o((()=>e._r_block?.delete()))}function T(u){(function({directive:l,entangle:u,evaluateLater:g,mapAttributes:T,mutateDom:_,prefixed:k}){T((e=>({name:e.name.replace(/^&/,k("bound:")),value:e.value}))),l("bound",((l,{expression:T,value:k,modifiers:x},{effect:N,cleanup:E})=>{if(!k)return void a("x-bound directive expects the presence of a bound property name
|
|
1
|
+
!function(){"use strict";function e(e,...t){const n=e(...t);return()=>{let e;return n((t=>e=t)),t=e,"function"==typeof t?.get?e.get():e;var t}}function t(e,...t){const n=e(...t);t[t.length-1]=`${t.at(-1)} = __val`;const o=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):o((()=>{}),{scope:{__val:e}})}}const n=Symbol();let o;const a=(...e)=>console.warn("alpine-gear.js:",...e),c=Array.isArray,r=e=>null==e,i=e=>"checkbox"===e.type||"radio"===e.type,l=e=>e instanceof HTMLTemplateElement,u=e=>e.nodeType===Node.ELEMENT_NODE,s=e=>c(e)?e:[e],d=(e,t)=>e==t,f=(e,t)=>e.findIndex((e=>e==t)),p=(e,t)=>e.includes(t),m=(e,t,n,o)=>(e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)),v=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function h(e,t,n=null){const{effect:o,release:a}=Alpine;let c,r,i=!1;const l=o((()=>{c=e(),i||(n?.deep&&JSON.stringify(c),r=c),(i||(n?.immediate??1))&&setTimeout((()=>{t(c,r),r=c}),0),i=!0}));return()=>a(l)}const b=new Map("value,checked,files,innerHTML,innerText,textContent,videoHeight,videoWidth,naturalHeight,naturalWidth,clientHeight,clientWidth,offsetHeight,offsetWidth,open,group".split(",").map((e=>[e.trim().toLowerCase(),e.trim()])));function g(e,t,{addScopeToNode:n,cleanup:o,initTree:a,mutateDom:c,scope:r={}}){if(e._r_block)return;document.body._r_block??=(()=>{const e=new MutationObserver((e=>{for(let t of e)for(let e of t.addedNodes)e._r_block?.update()}));return e.observe(document.body,{childList:!0,subtree:!0}),e})();let i=l(t)?[...t.content.cloneNode(!0).childNodes]:[t.cloneNode(!0)];c((()=>{for(let t of i)u(t)&&n(t,r,e),e.parentElement.insertBefore(t,e),u(t)&&a(t)})),e._r_block={template:t,update(){c((()=>{for(let t of i??[])e.parentElement.insertBefore(t,e)}))},delete(){e._r_block=null;for(let e of i??[])e.remove();i=null}},o((()=>e._r_block?.delete()))}function T(u){(function({directive:l,entangle:u,evaluateLater:g,mapAttributes:T,mutateDom:_,prefixed:k}){T((e=>({name:e.name.replace(/^&/,k("bound:")),value:e.value}))),l("bound",((l,{expression:T,value:k,modifiers:x},{effect:N,cleanup:E})=>{if(!k)return void a("x-bound directive expects the presence of a bound property name");const y=l.tagName.toUpperCase();T=T?.trim();const L=b.get(k.trim().replace("-","").toLowerCase());T||=L;const w=e(g,l,T),S=t(g,l,T),D=()=>d(l[L],w())||_((()=>l[L]=w())),H=()=>S((e=>"number"===e.type||"range"===e.type)(l)?function(e){return""===e?null:+e}(l[L]):l[L]);let M;switch(L){case"value":!function(){switch(y){case"INPUT":case"TEXTAREA":r(w())&&H(),N(D),E(m(l,"input",H)),M=!0;break;case"SELECT":queueMicrotask((()=>{r(w())&&H(),N((()=>function(e,t){for(const n of e.options)n.selected=f(t,n.value)>=0}(l,s(w()??[])))),E(m(l,"change",(()=>S(function(e){return e.multiple?[...e.selectedOptions].map((e=>e.value)):e.value}(l)))))})),M=!0}}();break;case"checked":i(l)&&(N(D),E(m(l,"change",H)),M=!0);break;case"files":"file"===l.type&&(E(m(l,"input",H)),M=!0);break;case"innerHTML":case"innerText":case"textContent":"true"===l.contentEditable&&(r(w())&&H(),N(D),E(m(l,"input",H)),M=!0);break;case"videoHeight":case"videoWidth":A("VIDEO","resize");break;case"naturalHeight":case"naturalWidth":A("IMG","load");break;case"clientHeight":case"clientWidth":case"offsetHeight":case"offsetWidth":E(function(e,t){return o??=new ResizeObserver((e=>{for(const t of e)for(const e of t.target[n]?.values()??[])e(t)})),e[n]??=new Set,e[n].add(t),o.observe(e),()=>{e[n].delete(t),e[n].size||(o.unobserve(e),e[n]=null)}}(l,H)),M=!0;break;case"open":"DETAILS"===y&&(r(w())&&H(),N(D),E(m(l,"toggle",H)),M=!0);break;case"group":i(l)&&(l.name||_((()=>l.name=T)),N((()=>_((()=>function(e,t){e.checked=c(t)?f(t,e.value)>=0:d(e.value,t)}(l,w()??[]))))),E(m(l,"input",(()=>S(function(e,t){if("radio"===e.type)return e.value;t=s(t);const n=f(t,e.value);return e.checked?n>=0||t.push(e.value):n>=0&&t.splice(n,1),t}(l,w()))))),M=!0)}if(!M){const n=p(x,"in")?"in":p(x,"out")?"out":"inout",o=T===k?(e=>{for(;e&&!e._x_dataStack;)e=(e._x_teleportBack??e).parentElement;return e})(l.parentNode):l;if(!l._x_dataStack)return void a("x-bound directive requires the presence of the x-data directive to bind component properties");if(!o)return void a(`x-bound directive cannot find the parent scope where the '${k}' property is defined`);const c={get:e(g,o,T),set:t(g,o,T)},r={get:e(g,l,k),set:t(g,l,k)};switch(n){case"in":E(h((()=>c.get()),(e=>r.set(v(e)))));break;case"out":E(h((()=>r.get()),(e=>c.set(v(e)))));break;default:E(u(c,r))}}function A(e,t){y===e&&(H(),E(m(l,t,H)),M=!0)}}))})(u),function({directive:t,mutateDom:n}){t("format",((t,{modifiers:o},{effect:a,evaluateLater:c})=>{const i=new Map,l=/{{(?<expr>.+?)}}/g,u=p(o,"once");function s(t){let n=i.get(t);return r(n)&&(n=e(c,t),i.set(t,n)),n}function d(e){u?(n((()=>e())),i.clear()):a((()=>n((()=>e()))))}!function e(t){switch(t.nodeType){case Node.TEXT_NODE:!function(e){const t=e.textContent.split(l);if(t.length>1){const o=new DocumentFragment;for(let e=0;t.length>e;e++)if(e%2==0)o.appendChild(document.createTextNode(t[e]));else{const n=s(t[e]),a=document.createTextNode("");o.append(a),d((()=>a.textContent=n()))}n((()=>e.parentElement.replaceChild(o,e)))}}(t);break;case Node.ELEMENT_NODE:!function(t){for(let n of t.childNodes)e(n)}(t),function(e){for(let t of e.attributes)if([...t.value.matchAll(l)].length){const e=t.value;d((()=>t.value=e.replace(l,((e,t)=>s(t)()))))}}(t)}}(t)}))}(u),function({addScopeToNode:e,directive:t,initTree:n,mutateDom:o}){t("fragment",((t,{},{cleanup:c})=>{l(t)?g(t,t,{addScopeToNode:e,cleanup:c,initTree:n,mutateDom:o}):a("x-fragment can only be used on a 'template' tag")}))}(u),function({addScopeToNode:t,directive:n,initTree:o,mutateDom:c}){n("match",((n,{},{cleanup:r,effect:i,evaluateLater:u})=>{if(!l(n))return void a("x-match can only be used on a 'template' tag");const s=[];for(let t of n.content.children){const n=t.getAttribute("x-case");null!==n?s.push({el:t,get_value:e(u,n)}):t.hasAttribute("x-default")&&s.push({el:t,get_value:()=>!0,default:!0})}const d=()=>n._r_block?.delete();i((()=>{let e;for(let t of s)t.get_value()&&!e&&(e=t);var a;e?(a=e,n._r_block?.template!==a.el&&(d(),g(n,a.el,{addScopeToNode:t,cleanup:r,initTree:o,mutateDom:c}))):d()}))}))}(u),function(e){e.directive("template",((e,{expression:t})=>{if(l(e))return void a("x-template cannot be used on a 'template' tag");const n=document.getElementById(t);l(n)?queueMicrotask((()=>{e.innerHTML="",e.append(n.content.cloneNode(!0))})):a("x-template directive can only reference the template tag")}))}(u),function({addScopeToNode:t,directive:n,initTree:o,mutateDom:c}){n("when",((n,{expression:r},{cleanup:i,effect:u,evaluateLater:s})=>{if(!l(n))return void a("x-when can only be used on a 'template' tag");const d=e(s,r);u((()=>d()?g(n,n,{addScopeToNode:t,cleanup:i,initTree:o,mutateDom:c}):n._r_block?.delete()))}))}(u)}document.addEventListener("alpine:init",(()=>{Alpine.plugin(T)}))}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramstack/alpinegear-main",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-preview.2",
|
|
4
4
|
"description": "@ramstack/alpinegear-main is a combined plugin that includes several Alpine.js directives, providing a convenient all-in-one package.",
|
|
5
5
|
"author": "Rameel Burhan",
|
|
6
6
|
"license": "MIT",
|