@stimulus-plumbers/controllers 0.2.0 → 0.2.2

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,14 +1,6 @@
1
1
  # @stimulus-plumbers/controllers
2
2
 
3
- Stimulus Plumbers controllers for WCAG 2.1+ compliant UI components.
4
-
5
- ## Philosophy
6
-
7
- **Use native HTML5 first.** Only use controllers when native elements have limitations.
8
-
9
- - ✅ `<details>` for disclosures
10
- - ✅ `<dialog>` for basic modals
11
- - ✅ **ModalController** for enhanced modals with accessibility features
3
+ Accessible Stimulus controllers following WCAG 2.1+ standards.
12
4
 
13
5
  ## Installation
14
6
 
@@ -16,128 +8,78 @@ Stimulus Plumbers controllers for WCAG 2.1+ compliant UI components.
16
8
  npm install @stimulus-plumbers/controllers
17
9
  ```
18
10
 
19
- ## ModalController
11
+ Requires `@hotwired/stimulus` ^2.0.0 or ^3.0.0 as a peer dependency.
20
12
 
21
- Full-featured accessible modal dialog. Supports both native `<dialog>` elements and custom implementations.
13
+ ## Usage
22
14
 
23
15
  ```javascript
24
16
  import { Application } from '@hotwired/stimulus';
25
- import { ModalController } from '@stimulus-plumbers/controllers';
17
+ import { ModalController, DatepickerController, CalendarMonthController } from '@stimulus-plumbers/controllers';
26
18
 
27
19
  const application = Application.start();
28
20
  application.register('modal', ModalController);
21
+ application.register('datepicker', DatepickerController);
22
+ application.register('calendar-month', CalendarMonthController);
29
23
  ```
30
24
 
25
+ ### ModalController
26
+
31
27
  Native `<dialog>` element:
28
+
32
29
  ```html
33
30
  <div data-controller="modal">
34
- <button data-action="modal#open">Open Modal</button>
35
-
31
+ <button data-action="modal#open">Open</button>
36
32
  <dialog data-modal-target="modal" aria-labelledby="modal-title">
37
- <h2 id="modal-title">Modal Title</h2>
38
- <p>Content...</p>
33
+ <h2 id="modal-title">Title</h2>
39
34
  <button data-action="modal#close">Close</button>
40
35
  </dialog>
41
36
  </div>
42
37
  ```
43
38
 
44
- Custom implementation:
39
+ Custom implementation with overlay:
40
+
45
41
  ```html
46
42
  <div data-controller="modal">
47
- <button data-action="modal#open">Open Modal</button>
48
-
49
- <div data-modal-target="overlay" class="modal-overlay" hidden>
50
- <div data-modal-target="modal"
51
- role="dialog"
52
- aria-modal="true"
53
- aria-labelledby="modal-title">
54
- <h2 id="modal-title">Modal Title</h2>
55
- <p>Content...</p>
43
+ <button data-action="modal#open">Open</button>
44
+ <div data-modal-target="overlay" hidden>
45
+ <div data-modal-target="modal" role="dialog" aria-modal="true" aria-labelledby="modal-title">
46
+ <h2 id="modal-title">Title</h2>
56
47
  <button data-action="modal#close">Close</button>
57
48
  </div>
58
49
  </div>
59
50
  </div>
60
51
  ```
61
52
 
62
- **Features:**
63
- - Focus trap with proper cycling
64
- - Escape key closes
65
- - Click outside closes
66
- - Focus restoration
67
- - Screen reader announcements
68
- - Body scroll lock (custom implementation)
69
-
70
- **Targets:** `modal`, `overlay` (optional)
71
- **Actions:** `open()`, `close()`
72
-
73
- ## Utilities
74
-
75
- ```javascript
76
- import {
77
- // Focus
78
- FocusTrap,
79
- FocusRestoration,
80
- getFocusableElements,
81
- focusFirst,
82
-
83
- // ARIA
84
- announce,
85
- generateId,
86
- ensureId,
87
- setExpanded,
88
- setPressed,
89
- setChecked,
90
- setDisabled,
91
-
92
- // Keyboard
93
- RovingTabIndex,
94
- isKey,
95
- isActivationKey,
96
- isArrowKey,
97
- preventDefault
98
- } from '@stimulus-plumbers/controllers';
99
- ```
53
+ ### DatepickerController
100
54
 
101
- **Example:**
55
+ Date picker backed by a calendar grid. Combines `datepicker` + `popover` controllers; uses `CalendarMonthController` as an outlet.
102
56
 
103
- ```javascript
104
- import { FocusTrap, announce } from '@stimulus-plumbers/controllers';
105
-
106
- export default class extends Controller {
107
- connect() {
108
- this.trap = new FocusTrap(this.element);
109
- }
110
-
111
- open() {
112
- this.trap.activate();
113
- announce('Panel opened');
114
- }
115
- }
57
+ ```html
58
+ <div data-controller="datepicker popover"
59
+ data-datepicker-calendar-month-outlet="[data-controller~='calendar-month']">
60
+ <input type="text" data-datepicker-target="display" data-action="focus->popover#show" />
61
+ <input type="hidden" data-datepicker-target="input" />
62
+
63
+ <div data-popover-target="content" hidden>
64
+ <button data-datepicker-target="previous">Prev</button>
65
+ <button data-datepicker-target="month"></button>
66
+ <button data-datepicker-target="year"></button>
67
+ <button data-datepicker-target="next">Next</button>
68
+
69
+ <div data-controller="calendar-month">
70
+ <div data-calendar-month-target="daysOfWeek"></div>
71
+ <div data-calendar-month-target="daysOfMonth"></div>
72
+ </div>
73
+ </div>
74
+ </div>
116
75
  ```
117
76
 
118
- ## Additional Controllers (Experimental)
119
-
120
- Available but not exported:
121
-
122
- - **CalendarMonthController** - Calendar widget with date navigation
123
- - **FormFieldController** - Dropdown field management
124
- - **PopoverController** - Content loading and visibility
125
- - **VisibilityController** - Show/hide with animations (prefer `<details>`)
126
- - **DismisserController** - Click-outside dismissal
127
- - **FlipperController** - Element positioning
128
- - **PannerController** - Scroll management
129
-
130
- ## Accessibility
131
-
132
- All controllers follow:
133
- - WCAG 2.1 Level AA
134
- - WAI-ARIA Authoring Practices
135
- - Keyboard navigation (Tab, Escape, Arrows)
136
- - Screen reader compatibility
137
-
138
- ## Browser Support
77
+ ## Other Controllers
139
78
 
140
- Chrome, Firefox, Safari, Edge (last 2 versions)
79
+ - `PopoverController` show/hide content with optional remote loading
80
+ - `DismisserController` — click-outside dismissal
81
+ - `FlipperController` — element positioning
82
+ - `PannerController` — scroll management
141
83
 
142
84
  ## License
143
85