@ramstack/alpinegear-bound 1.0.0 → 1.1.0-preview.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/alpinegear-bound.esm.js
CHANGED
|
@@ -102,7 +102,7 @@ const create_map = keys => new Map(
|
|
|
102
102
|
keys.split(",").map(v => [v.trim().toLowerCase(), v.trim()]));
|
|
103
103
|
|
|
104
104
|
function watch(get_value, callback, options = null) {
|
|
105
|
-
assert(Alpine, "Alpine is not defined
|
|
105
|
+
assert(Alpine, "Alpine is not defined");
|
|
106
106
|
|
|
107
107
|
const {
|
|
108
108
|
effect,
|
|
@@ -156,7 +156,7 @@ function plugin({ directive, entangle, evaluateLater, mapAttributes, mutateDom,
|
|
|
156
156
|
|
|
157
157
|
directive("bound", (el, { expression, value, modifiers }, { effect, cleanup }) => {
|
|
158
158
|
if (!value) {
|
|
159
|
-
warn("x-bound directive expects the presence of a bound property name
|
|
159
|
+
warn("x-bound directive expects the presence of a bound property name");
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -236,12 +236,12 @@ function plugin({ directive, entangle, evaluateLater, mapAttributes, mutateDom,
|
|
|
236
236
|
: el;
|
|
237
237
|
|
|
238
238
|
if (!el._x_dataStack) {
|
|
239
|
-
warn("x-bound directive requires the presence of the x-data directive to bind component properties
|
|
239
|
+
warn("x-bound directive requires the presence of the x-data directive to bind component properties");
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
if (!source_el) {
|
|
244
|
-
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined
|
|
244
|
+
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined`);
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -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 i=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):i((()=>{}),{scope:{__val:e}})}}const n=Symbol();let i;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,o=e=>null==e,c=e=>"checkbox"===e.type||"radio"===e.type,s=e=>r(e)?e:[e],u=(e,t)=>e==t,l=(e,t)=>e.findIndex((e=>e==t)),d=(e,t)=>e.includes(t),f=(e,t,n,i)=>(e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)),p=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function v(e,t,n=null){const{effect:i,release:a}=Alpine;let r,o,c=!1;const s=i((()=>{r=e(),c||(n?.deep&&JSON.stringify(r),o=r),(c||(n?.immediate??1))&&setTimeout((()=>{t(r,o),o=r}),0),c=!0}));return()=>a(s)}const h=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:g,entangle:b,evaluateLater:m,mapAttributes:k,mutateDom:x,prefixed:y}){k((e=>({name:e.name.replace(/^&/,y("bound:")),value:e.value}))),g("bound",((g,{expression:k,value:y,modifiers:w},{effect:E,cleanup:H})=>{if(!y)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 i=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):i((()=>{}),{scope:{__val:e}})}}const n=Symbol();let i;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,o=e=>null==e,c=e=>"checkbox"===e.type||"radio"===e.type,s=e=>r(e)?e:[e],u=(e,t)=>e==t,l=(e,t)=>e.findIndex((e=>e==t)),d=(e,t)=>e.includes(t),f=(e,t,n,i)=>(e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)),p=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function v(e,t,n=null){const{effect:i,release:a}=Alpine;let r,o,c=!1;const s=i((()=>{r=e(),c||(n?.deep&&JSON.stringify(r),o=r),(c||(n?.immediate??1))&&setTimeout((()=>{t(r,o),o=r}),0),c=!0}));return()=>a(s)}const h=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:g,entangle:b,evaluateLater:m,mapAttributes:k,mutateDom:x,prefixed:y}){k((e=>({name:e.name.replace(/^&/,y("bound:")),value:e.value}))),g("bound",((g,{expression:k,value:y,modifiers:w},{effect:E,cleanup:H})=>{if(!y)return void a("x-bound directive expects the presence of a bound property name");const T=g.tagName.toUpperCase();k=k?.trim();const _=h.get(y.trim().replace("-","").toLowerCase());k||=_;const L=e(m,g,k),S=t(m,g,k),W=()=>u(g[_],L())||x((()=>g[_]=L())),A=()=>S((e=>"number"===e.type||"range"===e.type)(g)?function(e){return""===e?null:+e}(g[_]):g[_]);let C;switch(_){case"value":!function(){switch(T){case"INPUT":case"TEXTAREA":o(L())&&A(),E(W),H(f(g,"input",A)),C=!0;break;case"SELECT":queueMicrotask((()=>{o(L())&&A(),E((()=>function(e,t){for(const n of e.options)n.selected=l(t,n.value)>=0}(g,s(L()??[])))),H(f(g,"change",(()=>S(function(e){return e.multiple?[...e.selectedOptions].map((e=>e.value)):e.value}(g)))))})),C=!0}}();break;case"checked":c(g)&&(E(W),H(f(g,"change",A)),C=!0);break;case"files":"file"===g.type&&(H(f(g,"input",A)),C=!0);break;case"innerHTML":case"innerText":case"textContent":"true"===g.contentEditable&&(o(L())&&A(),E(W),H(f(g,"input",A)),C=!0);break;case"videoHeight":case"videoWidth":N("VIDEO","resize");break;case"naturalHeight":case"naturalWidth":N("IMG","load");break;case"clientHeight":case"clientWidth":case"offsetHeight":case"offsetWidth":H(function(e,t){return i??=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),i.observe(e),()=>{e[n].delete(t),e[n].size||(i.unobserve(e),e[n]=null)}}(g,A)),C=!0;break;case"open":"DETAILS"===T&&(o(L())&&A(),E(W),H(f(g,"toggle",A)),C=!0);break;case"group":c(g)&&(g.name||x((()=>g.name=k)),E((()=>x((()=>function(e,t){e.checked=r(t)?l(t,e.value)>=0:u(e.value,t)}(g,L()??[]))))),H(f(g,"input",(()=>S(function(e,t){if("radio"===e.type)return e.value;t=s(t);const n=l(t,e.value);return e.checked?n>=0||t.push(e.value):n>=0&&t.splice(n,1),t}(g,L()))))),C=!0)}if(!C){const n=d(w,"in")?"in":d(w,"out")?"out":"inout",i=k===y?(e=>{for(;e&&!e._x_dataStack;)e=(e._x_teleportBack??e).parentElement;return e})(g.parentNode):g;if(!g._x_dataStack)return void a("x-bound directive requires the presence of the x-data directive to bind component properties");if(!i)return void a(`x-bound directive cannot find the parent scope where the '${y}' property is defined`);const r={get:e(m,i,k),set:t(m,i,k)},o={get:e(m,g,y),set:t(m,g,y)};switch(n){case"in":H(v((()=>r.get()),(e=>o.set(p(e)))));break;case"out":H(v((()=>o.get()),(e=>r.set(p(e)))));break;default:H(b(r,o))}}function N(e,t){T===e&&(A(),H(f(g,t,A)),C=!0)}}))}export{g as bound};
|
package/alpinegear-bound.js
CHANGED
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
keys.split(",").map(v => [v.trim().toLowerCase(), v.trim()]));
|
|
106
106
|
|
|
107
107
|
function watch(get_value, callback, options = null) {
|
|
108
|
-
assert(Alpine, "Alpine is not defined
|
|
108
|
+
assert(Alpine, "Alpine is not defined");
|
|
109
109
|
|
|
110
110
|
const {
|
|
111
111
|
effect,
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
|
|
160
160
|
directive("bound", (el, { expression, value, modifiers }, { effect, cleanup }) => {
|
|
161
161
|
if (!value) {
|
|
162
|
-
warn("x-bound directive expects the presence of a bound property name
|
|
162
|
+
warn("x-bound directive expects the presence of a bound property name");
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -239,12 +239,12 @@
|
|
|
239
239
|
: el;
|
|
240
240
|
|
|
241
241
|
if (!el._x_dataStack) {
|
|
242
|
-
warn("x-bound directive requires the presence of the x-data directive to bind component properties
|
|
242
|
+
warn("x-bound directive requires the presence of the x-data directive to bind component properties");
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
if (!source_el) {
|
|
247
|
-
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined
|
|
247
|
+
warn(`x-bound directive cannot find the parent scope where the '${ value }' property is defined`);
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
|
package/alpinegear-bound.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 i=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):i((()=>{}),{scope:{__val:e}})}}const n=Symbol();let i;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,o=e=>null==e,c=e=>"checkbox"===e.type||"radio"===e.type,s=e=>r(e)?e:[e],u=(e,t)=>e==t,l=(e,t)=>e.findIndex((e=>e==t)),d=(e,t)=>e.includes(t),p=(e,t,n,i)=>(e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)),f=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function v(e,t,n=null){const{effect:i,release:a}=Alpine;let r,o,c=!1;const s=i((()=>{r=e(),c||(n?.deep&&JSON.stringify(r),o=r),(c||(n?.immediate??1))&&setTimeout((()=>{t(r,o),o=r}),0),c=!0}));return()=>a(s)}const h=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:g,entangle:b,evaluateLater:m,mapAttributes:k,mutateDom:x,prefixed:y}){k((e=>({name:e.name.replace(/^&/,y("bound:")),value:e.value}))),g("bound",((g,{expression:k,value:y,modifiers:E},{effect:w,cleanup:H})=>{if(!y)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 i=e(...t);return e=>{let t;n((e=>t=e)),function(e){return"function"==typeof e?.set}(t)?t.set(e):i((()=>{}),{scope:{__val:e}})}}const n=Symbol();let i;const a=(...e)=>console.warn("alpine-gear.js:",...e),r=Array.isArray,o=e=>null==e,c=e=>"checkbox"===e.type||"radio"===e.type,s=e=>r(e)?e:[e],u=(e,t)=>e==t,l=(e,t)=>e.findIndex((e=>e==t)),d=(e,t)=>e.includes(t),p=(e,t,n,i)=>(e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)),f=e=>"object"==typeof e?JSON.parse(JSON.stringify(e)):e;function v(e,t,n=null){const{effect:i,release:a}=Alpine;let r,o,c=!1;const s=i((()=>{r=e(),c||(n?.deep&&JSON.stringify(r),o=r),(c||(n?.immediate??1))&&setTimeout((()=>{t(r,o),o=r}),0),c=!0}));return()=>a(s)}const h=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:g,entangle:b,evaluateLater:m,mapAttributes:k,mutateDom:x,prefixed:y}){k((e=>({name:e.name.replace(/^&/,y("bound:")),value:e.value}))),g("bound",((g,{expression:k,value:y,modifiers:E},{effect:w,cleanup:H})=>{if(!y)return void a("x-bound directive expects the presence of a bound property name");const L=g.tagName.toUpperCase();k=k?.trim();const T=h.get(y.trim().replace("-","").toLowerCase());k||=T;const _=e(m,g,k),S=t(m,g,k),A=()=>u(g[T],_())||x((()=>g[T]=_())),W=()=>S((e=>"number"===e.type||"range"===e.type)(g)?function(e){return""===e?null:+e}(g[T]):g[T]);let C;switch(T){case"value":!function(){switch(L){case"INPUT":case"TEXTAREA":o(_())&&W(),w(A),H(p(g,"input",W)),C=!0;break;case"SELECT":queueMicrotask((()=>{o(_())&&W(),w((()=>function(e,t){for(const n of e.options)n.selected=l(t,n.value)>=0}(g,s(_()??[])))),H(p(g,"change",(()=>S(function(e){return e.multiple?[...e.selectedOptions].map((e=>e.value)):e.value}(g)))))})),C=!0}}();break;case"checked":c(g)&&(w(A),H(p(g,"change",W)),C=!0);break;case"files":"file"===g.type&&(H(p(g,"input",W)),C=!0);break;case"innerHTML":case"innerText":case"textContent":"true"===g.contentEditable&&(o(_())&&W(),w(A),H(p(g,"input",W)),C=!0);break;case"videoHeight":case"videoWidth":N("VIDEO","resize");break;case"naturalHeight":case"naturalWidth":N("IMG","load");break;case"clientHeight":case"clientWidth":case"offsetHeight":case"offsetWidth":H(function(e,t){return i??=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),i.observe(e),()=>{e[n].delete(t),e[n].size||(i.unobserve(e),e[n]=null)}}(g,W)),C=!0;break;case"open":"DETAILS"===L&&(o(_())&&W(),w(A),H(p(g,"toggle",W)),C=!0);break;case"group":c(g)&&(g.name||x((()=>g.name=k)),w((()=>x((()=>function(e,t){e.checked=r(t)?l(t,e.value)>=0:u(e.value,t)}(g,_()??[]))))),H(p(g,"input",(()=>S(function(e,t){if("radio"===e.type)return e.value;t=s(t);const n=l(t,e.value);return e.checked?n>=0||t.push(e.value):n>=0&&t.splice(n,1),t}(g,_()))))),C=!0)}if(!C){const n=d(E,"in")?"in":d(E,"out")?"out":"inout",i=k===y?(e=>{for(;e&&!e._x_dataStack;)e=(e._x_teleportBack??e).parentElement;return e})(g.parentNode):g;if(!g._x_dataStack)return void a("x-bound directive requires the presence of the x-data directive to bind component properties");if(!i)return void a(`x-bound directive cannot find the parent scope where the '${y}' property is defined`);const r={get:e(m,i,k),set:t(m,i,k)},o={get:e(m,g,y),set:t(m,g,y)};switch(n){case"in":H(v((()=>r.get()),(e=>o.set(f(e)))));break;case"out":H(v((()=>o.get()),(e=>r.set(f(e)))));break;default:H(b(r,o))}}function N(e,t){L===e&&(W(),H(p(g,t,W)),C=!0)}}))}document.addEventListener("alpine:init",(()=>{Alpine.plugin(g)}))}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramstack/alpinegear-bound",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-preview.1",
|
|
4
4
|
"description": "@ramstack/alpinegear-bound provides the 'x-bound' Alpine.js directive, which allows for two-way binding of input elements and their associated data properties.",
|
|
5
5
|
"author": "Rameel Burhan",
|
|
6
6
|
"license": "MIT",
|