@ramstack/alpinegear-destroy 1.2.3 → 1.3.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 +52 -7
- package/alpinegear-destroy.esm.js +1 -1
- package/alpinegear-destroy.js +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
`@ramstack/alpinegear-destroy` is a plugin for [Alpine.js](https://alpinejs.dev/) that provides the `x-destroy` directive.
|
|
6
6
|
|
|
7
|
-
This directive is the opposite of `x-init` and allows you to
|
|
7
|
+
This directive is the opposite of `x-init` and allows you to hook into the cleanup phase of any element in Alpine,
|
|
8
|
+
running a callback when the element is removed from the DOM.
|
|
8
9
|
|
|
9
10
|
## Installation
|
|
10
11
|
|
|
@@ -16,7 +17,7 @@ To include the CDN version of this plugin, add the following `<script>` tag befo
|
|
|
16
17
|
<script src="https://cdn.jsdelivr.net/npm/@ramstack/alpinegear-destroy@1/alpinegear-destroy.min.js" defer></script>
|
|
17
18
|
|
|
18
19
|
<!-- alpine.js -->
|
|
19
|
-
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3
|
|
20
|
+
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3/dist/cdn.min.js" defer></script>
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
### Using NPM
|
|
@@ -41,25 +42,69 @@ In this example, when the `<div>` is removed, the message `Element destroyed` wi
|
|
|
41
42
|
|
|
42
43
|
```html
|
|
43
44
|
<div x-data="{ show: true, destroyed: false }">
|
|
44
|
-
<button @click="show = false">
|
|
45
|
+
<button @click="show = false">Remove element</button>
|
|
46
|
+
<button @click="show = true, destroyed = false">Reset</button>
|
|
45
47
|
|
|
46
48
|
<p x-show="destroyed">
|
|
47
|
-
|
|
49
|
+
Element destroyed
|
|
48
50
|
</p>
|
|
49
51
|
|
|
50
52
|
<template x-if="show">
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
</
|
|
53
|
+
<p x-destroy="destroyed = true">
|
|
54
|
+
Hello, World!
|
|
55
|
+
</p>
|
|
54
56
|
</template>
|
|
55
57
|
</div>
|
|
56
58
|
```
|
|
59
|
+
🚀 [Live demo | Alpine.js x-destroy: Handle DOM element removal](https://jsfiddle.net/rameel/qcnwm2b0/)
|
|
57
60
|
|
|
58
61
|
## Source code
|
|
59
62
|
You can find the source code for this plugin on GitHub:
|
|
60
63
|
|
|
61
64
|
https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/destroy
|
|
62
65
|
|
|
66
|
+
|
|
67
|
+
## Related projects
|
|
68
|
+
|
|
69
|
+
**[@ramstack/alpinegear-main](https://www.npmjs.com/package/@ramstack/alpinegear-main)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/main))<br>
|
|
70
|
+
Provides a combined plugin that includes several useful directives.
|
|
71
|
+
This package aggregates multiple individual plugins, offering a convenient all-in-one bundle.
|
|
72
|
+
Included directives: `x-bound`, `x-format`, `x-fragment`, `x-match`, `x-template`, and `x-when`.
|
|
73
|
+
|
|
74
|
+
**[@ramstack/alpinegear-bound](https://www.npmjs.com/package/@ramstack/alpinegear-bound)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/bound))<br>
|
|
75
|
+
Provides the `x-bound` directive, which allows for two-way binding of input elements and their associated data properties.
|
|
76
|
+
It works similarly to the binding provided by [Svelte](https://svelte.dev/docs/element-directives#bind-property)
|
|
77
|
+
and also supports synchronizing values between two `Alpine.js` data properties.
|
|
78
|
+
|
|
79
|
+
**[@ramstack/alpinegear-format](https://www.npmjs.com/package/@ramstack/alpinegear-format)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/format))<br>
|
|
80
|
+
Provides the `x-format` directive, which allows you to easily interpolate text using a template syntax similar to what's available in `Vue.js`.
|
|
81
|
+
|
|
82
|
+
**[@ramstack/alpinegear-template](https://www.npmjs.com/package/@ramstack/alpinegear-template)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/template))<br>
|
|
83
|
+
Provides the `x-template` directive, which allows you to define a template once anywhere in the DOM and reference it by its ID.
|
|
84
|
+
|
|
85
|
+
**[@ramstack/alpinegear-fragment](https://www.npmjs.com/package/@ramstack/alpinegear-fragment)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/fragment))<br>
|
|
86
|
+
Provides the `x-fragment` directive, which allows for fragment-like behavior similar to what's available in frameworks
|
|
87
|
+
like `Vue.js` or `React`, where multiple root elements can be grouped together.
|
|
88
|
+
|
|
89
|
+
**[@ramstack/alpinegear-match](https://www.npmjs.com/package/@ramstack/alpinegear-match)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/match))<br>
|
|
90
|
+
Provides the `x-match` directive, which functions similarly to the `switch` statement in many programming languages,
|
|
91
|
+
allowing you to conditionally render elements based on matching cases.
|
|
92
|
+
|
|
93
|
+
**[@ramstack/alpinegear-when](https://www.npmjs.com/package/@ramstack/alpinegear-when)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/when))<br>
|
|
94
|
+
Provides the `x-when` directive, which allows for conditional rendering of elements similar to `x-if`, but supports multiple root elements.
|
|
95
|
+
|
|
96
|
+
**[@ramstack/alpinegear-hotkey](https://www.npmjs.com/package/@ramstack/alpinegear-hotkey)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/hotkey))<br>
|
|
97
|
+
Provides the `x-hotkey` directive, which allows you to easily handle keyboard shortcuts within your Alpine.js components or application.
|
|
98
|
+
|
|
99
|
+
**[@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>
|
|
100
|
+
Provides the `x-router` and `x-route` directives, which enable client-side navigation and routing functionality within your Alpine.js application.
|
|
101
|
+
|
|
102
|
+
**[@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>
|
|
103
|
+
Provides a headless dialog directive for Alpine.js based on the native HTML `<dialog>` element.
|
|
104
|
+
It supports declarative composition, value-based close semantics, and both modal and non-modal dialogs,
|
|
105
|
+
with optional Promise-based imperative control.
|
|
106
|
+
|
|
107
|
+
|
|
63
108
|
## Contributions
|
|
64
109
|
Bug reports and contributions are welcome.
|
|
65
110
|
|
package/alpinegear-destroy.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramstack/alpinegear-destroy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "@ramstack/alpinegear-destroy provides 'x-destroy' Alpine.js directive, which is the opposite of 'x-init' and allows you to execute code when an element is removed from the DOM.",
|
|
5
5
|
"author": "Rameel Burhan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"alpine.js",
|
|
14
|
-
"alpinejs"
|
|
14
|
+
"alpinejs",
|
|
15
|
+
"alpinejs-directive",
|
|
16
|
+
"alpinejs-plugin"
|
|
15
17
|
],
|
|
16
18
|
"main": "alpinegear-destroy.js",
|
|
17
19
|
"module": "alpinegear-destroy.esm.js"
|