@ramstack/alpinegear-match 1.2.4 → 1.4.0
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/README.md +5 -0
- package/alpinegear-match.esm.js +2 -2
- package/alpinegear-match.esm.min.js +1 -1
- package/alpinegear-match.js +2 -2
- package/alpinegear-match.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,6 +144,11 @@ Provides the `x-hotkey` directive, which allows you to easily handle keyboard sh
|
|
|
144
144
|
**[@ramstack/alpinegear-router](https://www.npmjs.com/package/@ramstack/alpinegear-router)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/router))<br>
|
|
145
145
|
Provides the `x-router` and `x-route` directives, which enable client-side navigation and routing functionality within your Alpine.js application.
|
|
146
146
|
|
|
147
|
+
**[@ramstack/alpinegear-dialog](https://www.npmjs.com/package/@ramstack/alpinegear-dialog)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/dialog))<br>
|
|
148
|
+
Provides a headless dialog directive for Alpine.js based on the native HTML `<dialog>` element.
|
|
149
|
+
It supports declarative composition, value-based close semantics, and both modal and non-modal dialogs,
|
|
150
|
+
with optional Promise-based imperative control.
|
|
151
|
+
|
|
147
152
|
|
|
148
153
|
## Contributions
|
|
149
154
|
Bug reports and contributions are welcome.
|
package/alpinegear-match.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const warn = (...args) => console.warn("alpinegear.js:", ...args);
|
|
2
|
-
const is_template = el => el
|
|
2
|
+
const is_template = el => el.matches("template");
|
|
3
3
|
const is_element = el => el.nodeType === Node.ELEMENT_NODE;
|
|
4
4
|
|
|
5
5
|
function anchor_block(el, template, { addScopeToNode, cleanup, initTree, mutateDom, scope = {} }) {
|
|
@@ -123,4 +123,4 @@ function plugin({ addScopeToNode, directive, initTree, mutateDom }) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export { plugin as match };
|
|
126
|
+
export { plugin as match };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>e
|
|
1
|
+
const e=e=>e.matches("template"),t=e=>e.nodeType===Node.ELEMENT_NODE;function o(e,...t){const o=e(...t);return()=>{let e;return o(t=>e=t),t=e,"function"==typeof t?.get?e.get():e;var t}}function l({addScopeToNode:l,directive:n,initTree:r,mutateDom:c}){n("match",(n,{},{cleanup:a,effect:d,evaluateLater:u})=>{if(!e(n))return void console.warn("alpinegear.js:","x-match can only be used on a 'template' tag");const f=[];for(let e of n.content.children){const t=e.getAttribute("x-case");null!==t?f.push({el:e,get_value:o(u,t)}):e.hasAttribute("x-default")&&f.push({el:e,get_value:()=>!0,default:!0})}const i=()=>n._r_block?.delete();d(()=>{let o;for(let e of f)e.get_value()&&!o&&(o=e);var d;o?(d=o,n._r_block?.template!==d.el&&(i(),function(o,l,{addScopeToNode:n,cleanup:r,initTree:c,mutateDom:a,scope:d={}}){if(o._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 u=e(l)?[...l.content.cloneNode(!0).childNodes]:[l.cloneNode(!0)];a(()=>{for(let e of u)t(e)&&n(e,d,o),o.parentElement.insertBefore(e,o),t(e)&&c(e)}),o._r_block={template:l,update(){a(()=>{for(let e of u??[])o.parentElement.insertBefore(e,o)})},delete(){o._r_block=null;for(let e of u??[])e.remove();u=null}},r(()=>o._r_block?.delete())}(n,d.el,{addScopeToNode:l,cleanup:a,initTree:r,mutateDom:c}))):i()})})}export{l as match};
|
package/alpinegear-match.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const warn = (...args) => console.warn("alpinegear.js:", ...args);
|
|
5
|
-
const is_template = el => el
|
|
5
|
+
const is_template = el => el.matches("template");
|
|
6
6
|
const is_element = el => el.nodeType === Node.ELEMENT_NODE;
|
|
7
7
|
|
|
8
8
|
function anchor_block(el, template, { addScopeToNode, cleanup, initTree, mutateDom, scope = {} }) {
|
|
@@ -128,4 +128,4 @@
|
|
|
128
128
|
|
|
129
129
|
document.addEventListener("alpine:init", () => { Alpine.plugin(plugin); });
|
|
130
130
|
|
|
131
|
-
})();
|
|
131
|
+
})();
|
package/alpinegear-match.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";const e=e=>e
|
|
1
|
+
!function(){"use strict";const e=e=>e.matches("template"),t=e=>e.nodeType===Node.ELEMENT_NODE;function o(e,...t){const o=e(...t);return()=>{let e;return o(t=>e=t),t=e,"function"==typeof t?.get?e.get():e;var t}}function n({addScopeToNode:n,directive:l,initTree:r,mutateDom:c}){l("match",(l,{},{cleanup:a,effect:u,evaluateLater:d})=>{if(!e(l))return void console.warn("alpinegear.js:","x-match can only be used on a 'template' tag");const i=[];for(let e of l.content.children){const t=e.getAttribute("x-case");null!==t?i.push({el:e,get_value:o(d,t)}):e.hasAttribute("x-default")&&i.push({el:e,get_value:()=>!0,default:!0})}const f=()=>l._r_block?.delete();u(()=>{let o;for(let e of i)e.get_value()&&!o&&(o=e);var u;o?(u=o,l._r_block?.template!==u.el&&(f(),function(o,n,{addScopeToNode:l,cleanup:r,initTree:c,mutateDom:a,scope:u={}}){if(o._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 d=e(n)?[...n.content.cloneNode(!0).childNodes]:[n.cloneNode(!0)];a(()=>{for(let e of d)t(e)&&l(e,u,o),o.parentElement.insertBefore(e,o),t(e)&&c(e)}),o._r_block={template:n,update(){a(()=>{for(let e of d??[])o.parentElement.insertBefore(e,o)})},delete(){o._r_block=null;for(let e of d??[])e.remove();d=null}},r(()=>o._r_block?.delete())}(l,u.el,{addScopeToNode:n,cleanup:a,initTree:r,mutateDom:c}))):f()})})}document.addEventListener("alpine:init",()=>{Alpine.plugin(n)})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramstack/alpinegear-match",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "@ramstack/alpinegear-match provides the 'x-match' Alpine.js directive, which functions similarly to the 'switch' statement in many programming languages, allowing to conditionally render elements based on matching cases.",
|
|
5
5
|
"author": "Rameel Burhan",
|
|
6
6
|
"license": "MIT",
|