@ramstack/alpinegear-main 1.4.2 → 1.4.4

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 CHANGED
@@ -1,187 +1,163 @@
1
- # @ramstack/alpinegear-main
2
- [![NPM](https://img.shields.io/npm/v/@ramstack/alpinegear-main)](https://www.npmjs.com/package/@ramstack/alpinegear-main)
3
- [![MIT](https://img.shields.io/github/license/rameel/ramstack.alpinegear.js)](https://github.com/rameel/ramstack.alpinegear.js/blob/main/LICENSE)
4
-
5
- `@ramstack/alpinegear-main` is a combined plugin for [Alpine.js](https://alpinejs.dev/) that includes several useful directives. This plugin aggregates multiple individual plugins, providing a convenient all-in-one package.
6
-
7
- ## Installation
8
-
9
- ### Using CDN
10
- To include the CDN version of this plugin, add the following `<script>` tag before the core `alpine.js` file:
11
-
12
- ```html
13
- <!-- alpine.js plugin -->
14
- <script src="https://cdn.jsdelivr.net/npm/@ramstack/alpinegear-main@1/alpinegear-main.min.js" defer></script>
15
-
16
- <!-- alpine.js -->
17
- <script src="https://cdn.jsdelivr.net/npm/alpinejs@3/dist/cdn.min.js" defer></script>
18
- ```
19
-
20
- ### Using NPM
21
- Alternatively, you can install the plugin via `npm`:
22
-
23
- ```bash
24
- npm install --save @ramstack/alpinegear-main
25
- ```
26
-
27
- Then initialize it in your bundle:
28
-
29
- ```js
30
- import Alpine from "alpinejs";
31
- import main from "@ramstack/alpinegear-main";
32
-
33
- Alpine.plugin(main);
34
- Alpine.start();
35
- ```
36
-
37
- ## Included Plugins
38
-
39
- **[@ramstack/alpinegear-bound](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/bound)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/bound))<br>
40
- Provides the `x-bound` directive, which allows for two-way binding of input elements and their associated data properties. It works similarly to the binding provided by [Svelte](https://svelte.dev/docs/element-directives#bind-property) and also supports synchronizing values between two `Alpine.js` data properties.
41
-
42
- ```html
43
- <div x-data="{ width: 0, height: 0, files: [] }">
44
- <input &files="files" type="file" accept="image/jpeg" />
45
-
46
- <img &naturalwidth="width" &naturalheight="height" src="..." />
47
-
48
- ...
49
-
50
- For other examples, see README
51
-
52
- </div>
53
- ```
54
-
55
-
56
- **[@ramstack/alpinegear-format](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/format)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/format))<br>
57
- Provides `x-format` directive, which allows you to easily interpolate text using a template syntax similar to what's available in `Vue.js`.
58
-
59
- ```html
60
- <div x-data="{ message: 'Hello, World!'}" x-format>
61
- <span>Message: {{ message }}</span>
62
- </div>
63
- ```
64
-
65
-
66
- **[@ramstack/alpinegear-template](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/template)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/template))<br>
67
- Provides `x-template` directive, allowing to define a template once anywhere in the DOM and reference it by its ID.
68
-
69
- This helps avoid duplicating templates, simplifying markup and making it easier to manage.
70
-
71
- Moreover, it enables recursive templates, allowing you to create components like a **tree view** with ease,
72
- something that would otherwise be quite complex to implement.
73
-
74
- ```html
75
- <template id="treeitem">
76
- <span x-format>{{ model.name }}</span>
77
-
78
- <template x-if="model.list">
79
- <ul>
80
- <template x-for="item in model.list">
81
- <li x-template="treeitem" x-data="{ model: item }"></li>
82
- </template>
83
- </ul>
84
- </template>
85
- </template>
86
-
87
- <ul x-data="json">
88
- <li x-template="treeitem"></li>
89
- </ul>
90
- ```
91
-
92
-
93
- **[@ramstack/alpinegear-fragment](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/fragment)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/fragment))<br>
94
- Provides the `x-fragment` directive, allowing for fragment-like behavior similar to what's available in frameworks like `Vue.js` or `React`, where multiple root elements can be grouped together.
95
-
96
- It is particularly useful when you want to avoid wrapping elements in unnecessary container tags.
97
-
98
- ```html
99
- <dl>
100
- <template x-for="item in items" :key="item.id">
101
- <template x-fragment>
102
- <dt x-text="item.term"></dt>
103
- <dd x-text="item.description"></dd>
104
- </template>
105
- </template>
106
- </dl>
107
- ```
108
-
109
-
110
- **[@ramstack/alpinegear-match](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/match)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/match))<br>
111
- Provides the `x-match` directive, which functions similarly to the `switch` statement in many programming languages, allowing to conditionally render elements based on matching cases.
112
-
113
- ```html
114
- <template x-for="n in numbers">
115
- <template x-match>
116
- <div x-case="n % 3 == 0 && n % 5 == 0">Fizz Buzz</div>
117
- <div x-case="n % 3 == 0">Fizz</div>
118
- <div x-case="n % 5 == 0">Buzz</div>
119
- <div x-default x-text="n"></div>
120
- </template>
121
- </template>
122
- ```
123
-
124
-
125
- **[@ramstack/alpinegear-when](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/when)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/when))<br>
126
- Provides the `x-when` directive, which allows for conditional rendering of elements similar to `x-if`, but supports multiple root elements.
127
-
128
- ```html
129
- <template x-for="item in items" :key="item.id">
130
- <template x-when="item.visible">
131
- <dt x-text="item.term"></dt>
132
- <dd x-text="item.description"></dd>
133
- </template>
134
- </template>
135
- ```
136
-
137
- ## Source Code
138
- You can find the source code for this plugin on GitHub:
139
-
140
- https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/main
141
-
142
- ## Related projects
143
-
144
- **[@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>
145
- Provides the `x-bound` directive, which allows for two-way binding of input elements and their associated data properties.
146
- It works similarly to the binding provided by [Svelte](https://svelte.dev/docs/element-directives#bind-property)
147
- and also supports synchronizing values between two `Alpine.js` data properties.
148
-
149
- **[@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>
150
- Provides the `x-format` directive, which allows you to easily interpolate text using a template syntax similar to what's available in `Vue.js`.
151
-
152
- **[@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>
153
- Provides the `x-template` directive, which allows you to define a template once anywhere in the DOM and reference it by its ID.
154
-
155
- **[@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>
156
- Provides the `x-fragment` directive, which allows for fragment-like behavior similar to what's available in frameworks
157
- like `Vue.js` or `React`, where multiple root elements can be grouped together.
158
-
159
- **[@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>
160
- Provides the `x-match` directive, which functions similarly to the `switch` statement in many programming languages,
161
- allowing you to conditionally render elements based on matching cases.
162
-
163
- **[@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>
164
- Provides the `x-when` directive, which allows for conditional rendering of elements similar to `x-if`, but supports multiple root elements.
165
-
166
- **[@ramstack/alpinegear-destroy](https://www.npmjs.com/package/@ramstack/alpinegear-destroy)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/destroy))<br>
167
- Provides the `x-destroy` directive, which is the opposite of `x-init` and allows you to hook into the cleanup phase
168
- of any element, running a callback when the element is removed from the DOM.
169
-
170
- **[@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>
171
- Provides the `x-hotkey` directive, which allows you to easily handle keyboard shortcuts within your Alpine.js components or application.
172
-
173
- **[@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>
174
- Provides the `x-router` and `x-route` directives, which enable client-side navigation and routing functionality within your Alpine.js application.
175
-
176
- **[@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>
177
- Provides a headless dialog directive for Alpine.js based on the native HTML `<dialog>` element.
178
- It supports declarative composition, value-based close semantics, and both modal and non-modal dialogs,
179
- with optional Promise-based imperative control.
180
-
181
-
182
- ## Contributions
183
- Bug reports and contributions are welcome.
184
-
185
- ## License
186
- This package is released as open source under the **MIT License**.
187
- See the [LICENSE](https://github.com/rameel/ramstack.alpinegear.js/blob/main/LICENSE) file for more details.
1
+ # @ramstack/alpinegear-main
2
+ [![NPM](https://img.shields.io/npm/v/@ramstack/alpinegear-main)](https://www.npmjs.com/package/@ramstack/alpinegear-main)
3
+ [![MIT](https://img.shields.io/github/license/rameel/ramstack.alpinegear.js)](https://github.com/rameel/ramstack.alpinegear.js/blob/main/LICENSE)
4
+
5
+ `@ramstack/alpinegear-main` is a combined plugin for [Alpine.js](https://alpinejs.dev/) that includes several useful directives.
6
+ This plugin aggregates multiple individual plugins, providing a convenient all-in-one package.
7
+
8
+ ## Installation
9
+
10
+ ### Using CDN
11
+ To include the CDN version of this plugin, add the following `<script>` tag before the core `alpine.js` file:
12
+
13
+ ```html
14
+ <!-- alpine.js plugin -->
15
+ <script src="https://cdn.jsdelivr.net/npm/@ramstack/alpinegear-main@1/alpinegear-main.min.js" defer></script>
16
+
17
+ <!-- alpine.js -->
18
+ <script src="https://cdn.jsdelivr.net/npm/alpinejs@3/dist/cdn.min.js" defer></script>
19
+ ```
20
+
21
+ ### Using NPM
22
+ Alternatively, you can install the plugin via `npm`:
23
+
24
+ ```bash
25
+ npm install --save @ramstack/alpinegear-main
26
+ ```
27
+
28
+ Then initialize it in your bundle:
29
+
30
+ ```js
31
+ import Alpine from "alpinejs";
32
+ import main from "@ramstack/alpinegear-main";
33
+
34
+ Alpine.plugin(main);
35
+ Alpine.start();
36
+ ```
37
+
38
+ ## Included Plugins
39
+
40
+ **[@ramstack/alpinegear-bound](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/bound)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/bound))<br>
41
+ Provides the `x-bound` directive, which allows for two-way binding of input elements and their associated data properties.
42
+ It works similarly to the binding provided by [Svelte](https://svelte.dev/docs/element-directives#bind-property)
43
+ and also supports synchronizing values between two `Alpine.js` data properties.
44
+
45
+ ```html
46
+ <div x-data="{ width: 0, height: 0, files: [] }">
47
+ <input &files="files" type="file" accept="image/jpeg" />
48
+
49
+ <img &naturalwidth="width" &naturalheight="height" src="..." />
50
+
51
+ ...
52
+
53
+ For other examples, see README
54
+
55
+ </div>
56
+ ```
57
+
58
+
59
+ **[@ramstack/alpinegear-format](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/format)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/format))<br>
60
+ Provides `x-format` directive, which allows you to easily interpolate text using a template syntax
61
+ similar to what's available in `Vue.js`.
62
+
63
+ ```html
64
+ <div x-data="{ message: 'Hello, World!'}" x-format>
65
+ <span>Message: {{ message }}</span>
66
+ </div>
67
+ ```
68
+
69
+
70
+ **[@ramstack/alpinegear-template](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/template)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/template))<br>
71
+ Provides `x-template` directive, allowing to define a template once anywhere in the DOM and reference it by its ID.
72
+
73
+ This helps avoid duplicating templates, simplifying markup and making it easier to manage.
74
+
75
+ Moreover, it enables recursive templates, allowing you to create components like a **tree view** with ease,
76
+ something that would otherwise be quite complex to implement.
77
+
78
+ ```html
79
+ <template id="treeitem">
80
+ <span x-format>{{ model.name }}</span>
81
+
82
+ <template x-if="model.list">
83
+ <ul>
84
+ <template x-for="item in model.list">
85
+ <li x-template="treeitem" x-data="{ model: item }"></li>
86
+ </template>
87
+ </ul>
88
+ </template>
89
+ </template>
90
+
91
+ <ul x-data="json">
92
+ <li x-template="treeitem"></li>
93
+ </ul>
94
+ ```
95
+
96
+
97
+ **[@ramstack/alpinegear-fragment](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/fragment)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/fragment))<br>
98
+ Provides the `x-fragment` directive, allowing for fragment-like behavior similar to what's available in frameworks
99
+ like `Vue.js` or `React`, where multiple root elements can be grouped together.
100
+
101
+ It is particularly useful when you want to avoid wrapping elements in unnecessary container tags.
102
+
103
+ ```html
104
+ <dl>
105
+ <template x-for="item in items" :key="item.id">
106
+ <template x-fragment>
107
+ <dt x-text="item.term"></dt>
108
+ <dd x-text="item.description"></dd>
109
+ </template>
110
+ </template>
111
+ </dl>
112
+ ```
113
+
114
+
115
+ **[@ramstack/alpinegear-match](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/match)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/match))<br>
116
+ Provides the `x-match` directive, which functions similarly to the `switch` statement in many programming languages,
117
+ allowing to conditionally render elements based on matching cases.
118
+
119
+ ```html
120
+ <template x-for="n in numbers">
121
+ <template x-match>
122
+ <div x-case="n % 3 == 0 && n % 5 == 0">Fizz Buzz</div>
123
+ <div x-case="n % 3 == 0">Fizz</div>
124
+ <div x-case="n % 5 == 0">Buzz</div>
125
+ <div x-default x-text="n"></div>
126
+ </template>
127
+ </template>
128
+ ```
129
+
130
+
131
+ **[@ramstack/alpinegear-when](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/when)** ([README](https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/when))<br>
132
+ Provides the `x-when` directive, which allows for conditional rendering of elements similar to `x-if`,
133
+ but supports multiple root elements.
134
+
135
+ ```html
136
+ <template x-for="item in items" :key="item.id">
137
+ <template x-when="item.visible">
138
+ <dt x-text="item.term"></dt>
139
+ <dd x-text="item.description"></dd>
140
+ </template>
141
+ </template>
142
+ ```
143
+
144
+ ## Source Code
145
+ You can find the source code for this plugin on GitHub:
146
+
147
+ https://github.com/rameel/ramstack.alpinegear.js/tree/main/src/plugins/main
148
+
149
+
150
+ ## Related packages
151
+ This package is part of **[AlpineGear](https://github.com/rameel/ramstack.alpinegear.js)** —
152
+ a collection of utilities and directives for [Alpine.js](https://alpinejs.dev).
153
+
154
+ You can find the full list of related packages and their documentation here:
155
+ https://github.com/rameel/ramstack.alpinegear.js
156
+
157
+
158
+ ## Contributions
159
+ Bug reports and contributions are welcome.
160
+
161
+ ## License
162
+ This package is released as open source under the **MIT License**.
163
+ See the [LICENSE](https://github.com/rameel/ramstack.alpinegear.js/blob/main/LICENSE) file for more details.