@voidable/ui-hotwire 0.0.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/LICENSE.md ADDED
@@ -0,0 +1,25 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright © `2026` `Kaz Walker`
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the “Software”), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @voidable/ui-hotwire
2
+
3
+ Hotwire (Turbo + Stimulus) adapter for [Voidable UI](https://github.com/VoidableUI/Voidable) web components.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @voidable/ui @voidable/theme @voidable/ui-hotwire
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ ```js
14
+ import { Application } from '@hotwired/stimulus';
15
+ import { VoidEventController, VoidTurbo } from '@voidable/ui-hotwire';
16
+
17
+ const application = Application.start();
18
+ application.register('void-event', VoidEventController);
19
+ VoidTurbo.start();
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```erb
25
+ <void-button
26
+ data-controller="void-event"
27
+ data-void-event-events-value="void-click"
28
+ data-action="void-click->form#submit"
29
+ >
30
+ Save
31
+ </void-button>
32
+
33
+ <void-select
34
+ data-controller="void-event"
35
+ data-void-event-events-value="void-change"
36
+ data-action="void-change->filter#update"
37
+ >
38
+ <option value="a">Option A</option>
39
+ <option value="b">Option B</option>
40
+ </void-select>
41
+ ```
42
+
43
+ ## Documentation
44
+
45
+ - [Storybook](https://voidableui.github.io/Voidable/)
46
+ - [GitHub](https://github.com/VoidableUI/Voidable)
@@ -0,0 +1,52 @@
1
+ import { Controller as e } from "@hotwired/stimulus";
2
+ //#region src/controller.ts
3
+ var t = class extends e {
4
+ static values = { events: {
5
+ type: String,
6
+ default: ""
7
+ } };
8
+ _bindings = [];
9
+ connect() {
10
+ this._bind();
11
+ }
12
+ eventsValueChanged() {
13
+ this._unbind(), this._bind();
14
+ }
15
+ disconnect() {
16
+ this._unbind();
17
+ }
18
+ _bind() {
19
+ let e = this.eventsValue.split(",").filter(Boolean);
20
+ for (let t of e) {
21
+ let e = ((e) => {
22
+ this.dispatch(t, {
23
+ detail: e.detail,
24
+ prefix: ""
25
+ });
26
+ });
27
+ this.element.addEventListener(t, e), this._bindings.push({
28
+ event: t,
29
+ handler: e
30
+ });
31
+ }
32
+ }
33
+ _unbind() {
34
+ for (let { event: e, handler: t } of this._bindings) this.element.removeEventListener(e, t);
35
+ this._bindings = [];
36
+ }
37
+ }, n = [
38
+ "aria-expanded",
39
+ "aria-selected",
40
+ "aria-checked",
41
+ "aria-hidden",
42
+ "open",
43
+ "active",
44
+ "checked",
45
+ "selected"
46
+ ], r = { start() {
47
+ document.addEventListener("turbo:before-morph-attribute", ((e) => {
48
+ e.target.tagName?.startsWith("VOID-") && n.includes(e.detail.attributeName) && e.preventDefault();
49
+ }));
50
+ } };
51
+ //#endregion
52
+ export { t as VoidEventController, r as VoidTurbo };
@@ -0,0 +1,48 @@
1
+ import { Controller } from '@hotwired/stimulus';
2
+
3
+ /**
4
+ * Stimulus controller that bridges CustomEvents from Voidable web components
5
+ * so parent controllers can handle them via `data-action`.
6
+ *
7
+ * Usage:
8
+ * ```html
9
+ * <void-button
10
+ * data-controller="void-event"
11
+ * data-void-event-events-value="void-click"
12
+ * data-action="void-click->form#submit"
13
+ * >
14
+ * Save
15
+ * </void-button>
16
+ * ```
17
+ */
18
+ export declare class VoidEventController extends Controller {
19
+ static values: {
20
+ events: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ };
25
+ eventsValue: string;
26
+ private _bindings;
27
+ connect(): void;
28
+ eventsValueChanged(): void;
29
+ disconnect(): void;
30
+ private _bind;
31
+ private _unbind;
32
+ }
33
+
34
+ /**
35
+ * Turbo morph integration to preserve client-managed attributes on `VOID-*`
36
+ * elements during page morphs.
37
+ *
38
+ * Usage:
39
+ * ```js
40
+ * import { VoidTurbo } from '@voidable/ui-hotwire';
41
+ * VoidTurbo.start();
42
+ * ```
43
+ */
44
+ export declare const VoidTurbo: {
45
+ start(): void;
46
+ };
47
+
48
+ export { }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@voidable/ui-hotwire",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "development": "./src/index.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": ["dist"],
14
+ "scripts": {
15
+ "build": "vite build",
16
+ "typecheck": "tsc --noEmit"
17
+ },
18
+ "peerDependencies": {
19
+ "@voidable/ui": "workspace:*",
20
+ "@hotwired/stimulus": "^3.2.0",
21
+ "@hotwired/turbo": "^8.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@voidable/ui": "workspace:*",
25
+ "@hotwired/stimulus": "^3.2.0",
26
+ "@hotwired/turbo": "^8.0.0",
27
+ "typescript": "^6.0.0",
28
+ "vite": "^8.0.0",
29
+ "vite-plugin-dts": "^4.5.0"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/VoidableUI/Voidable",
34
+ "directory": "packages/hotwire"
35
+ }
36
+ }