@stimulus-plumbers/controllers 0.2.7 → 0.2.8
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 +78 -59
- package/dist/stimulus-plumbers-controllers.es.js +734 -248
- package/dist/stimulus-plumbers-controllers.umd.js +1 -1
- package/package.json +1 -1
- package/src/controllers/calendar_month_observer_controller.js +9 -6
- package/src/controllers/clipboard_controller.js +27 -0
- package/src/controllers/{datepicker_controller.js → combobox_date_controller.js} +19 -33
- package/src/controllers/combobox_dropdown_controller.js +88 -0
- package/src/controllers/combobox_time_controller.js +56 -0
- package/src/controllers/input_combobox_controller.js +60 -0
- package/src/controllers/input_format_controller.js +99 -0
- package/src/controllers/modal_controller.js +3 -8
- package/src/controllers/popover_controller.js +1 -1
- package/src/index.js +10 -5
- package/src/plumbers/combobox_dropdown.js +60 -0
- package/src/plumbers/content_loader.js +2 -2
- package/src/plumbers/index.js +2 -0
- package/src/plumbers/input_format/formatters/credit_card.js +69 -0
- package/src/plumbers/input_format/formatters/currency.js +87 -0
- package/src/plumbers/input_format/formatters/date.js +98 -0
- package/src/plumbers/input_format/formatters/phone.js +73 -0
- package/src/plumbers/input_format/formatters/plain.js +10 -0
- package/src/plumbers/input_format/formatters/time.js +62 -0
- package/src/plumbers/input_format/index.js +90 -0
package/README.md
CHANGED
|
@@ -1,86 +1,105 @@
|
|
|
1
1
|
# @stimulus-plumbers/controllers
|
|
2
2
|
|
|
3
|
+
[![Version][npm_badge]][npm]
|
|
4
|
+
[![CI][ci_badge]][ci]
|
|
5
|
+
|
|
3
6
|
Accessible Stimulus controllers following WCAG 2.1+ standards.
|
|
4
7
|
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Node.js >= 18
|
|
11
|
+
- `@hotwired/stimulus` ^2.0 or ^3.0 (peer dependency)
|
|
12
|
+
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
16
|
npm install @stimulus-plumbers/controllers
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
## Setup
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
Register the controllers you need with your Stimulus application:
|
|
14
22
|
|
|
15
23
|
```javascript
|
|
16
|
-
import { Application } from '@hotwired/stimulus'
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
import { Application } from '@hotwired/stimulus'
|
|
25
|
+
import {
|
|
26
|
+
InputComboboxController,
|
|
27
|
+
InputFormatController,
|
|
28
|
+
ComboboxDateController,
|
|
29
|
+
ComboboxTimeController,
|
|
30
|
+
ComboboxDropdownController,
|
|
31
|
+
CalendarMonthController,
|
|
32
|
+
CalendarMonthObserverController,
|
|
33
|
+
ModalController,
|
|
34
|
+
PopoverController,
|
|
35
|
+
DismisserController,
|
|
36
|
+
FlipperController,
|
|
37
|
+
ClipboardController,
|
|
38
|
+
} from '@stimulus-plumbers/controllers'
|
|
39
|
+
|
|
40
|
+
const application = Application.start()
|
|
41
|
+
|
|
42
|
+
application.register('input-combobox', InputComboboxController)
|
|
43
|
+
application.register('input-format', InputFormatController)
|
|
44
|
+
application.register('combobox-date', ComboboxDateController)
|
|
45
|
+
application.register('combobox-time', ComboboxTimeController)
|
|
46
|
+
application.register('combobox-dropdown', ComboboxDropdownController)
|
|
47
|
+
application.register('calendar-month', CalendarMonthController)
|
|
48
|
+
application.register('calendar-month-observer', CalendarMonthObserverController)
|
|
49
|
+
application.register('modal', ModalController)
|
|
50
|
+
application.register('popover', PopoverController)
|
|
51
|
+
application.register('dismisser', DismisserController)
|
|
52
|
+
application.register('flipper', FlipperController)
|
|
53
|
+
application.register('clipboard', ClipboardController)
|
|
23
54
|
```
|
|
24
55
|
|
|
25
|
-
|
|
56
|
+
## Controllers
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
| Controller | Description | Docs |
|
|
59
|
+
|-----------|-------------|------|
|
|
60
|
+
| `input-combobox` | Wrapper: trigger, popover, hidden value | [docs/component/combobox.md](docs/component/combobox.md#input-combobox) |
|
|
61
|
+
| `input-format` | Formats and displays values | [docs/component/combobox.md](docs/component/combobox.md#input-format) |
|
|
62
|
+
| `combobox-date` | Calendar grid date picker | [docs/component/combobox.md](docs/component/combobox.md#combobox-date) |
|
|
63
|
+
| `combobox-time` | Drum/scroll-wheel time picker | [docs/component/combobox.md](docs/component/combobox.md#combobox-time) |
|
|
64
|
+
| `combobox-dropdown` | Listbox with fuzzy filter or server fetch | [docs/component/combobox.md](docs/component/combobox.md#combobox-dropdown) |
|
|
65
|
+
| `calendar-month` | Calendar grid renderer | [docs/component/calendar.md](docs/component/calendar.md) |
|
|
66
|
+
| `calendar-month-observer` | Click-to-select handler for calendar grids | [docs/component/calendar.md](docs/component/calendar.md#calendar-month-observer) |
|
|
67
|
+
| `modal` | Native `<dialog>` or custom overlay | [docs/component/modal.md](docs/component/modal.md) |
|
|
68
|
+
| `popover` | Show/hide content with optional remote load | [docs/component/popover.md](docs/component/popover.md) |
|
|
69
|
+
| `dismisser` | Click-outside dismissal | [docs/component/dismisser.md](docs/component/dismisser.md) |
|
|
70
|
+
| `flipper` | Floating element positioning | [docs/component/flipper.md](docs/component/flipper.md) |
|
|
71
|
+
| `clipboard` | Copy-to-clipboard and paste interception | [docs/component/clipboard.md](docs/component/clipboard.md) |
|
|
28
72
|
|
|
29
|
-
|
|
30
|
-
<div data-controller="modal">
|
|
31
|
-
<button data-action="modal#open">Open</button>
|
|
32
|
-
<dialog data-modal-target="modal" aria-labelledby="modal-title">
|
|
33
|
-
<h2 id="modal-title">Title</h2>
|
|
34
|
-
<button data-action="modal#close">Close</button>
|
|
35
|
-
</dialog>
|
|
36
|
-
</div>
|
|
37
|
-
```
|
|
73
|
+
## Method naming convention
|
|
38
74
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
<div data-controller="modal">
|
|
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>
|
|
47
|
-
<button data-action="modal#close">Close</button>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
```
|
|
75
|
+
Controllers follow a consistent naming pattern:
|
|
52
76
|
|
|
53
|
-
|
|
77
|
+
| Pattern | Parameter | Role | Example |
|
|
78
|
+
|---------|-----------|------|---------|
|
|
79
|
+
| `x(value)` | raw value | Programmatic API — pure logic, callable directly | `select('us')`, `format('4242…')`, `step(1)`, `filter('query')` |
|
|
80
|
+
| `onX(event)` | DOM event | Event adapter — extracts payload, calls programmatic API | `onSelect(event)`, `onChange(event)`, `onPaste(event)`, `onInput(event)`, `onNavigate(event)` |
|
|
81
|
+
| `past()` | — | Plumber callback — called by plumber after async operation completes | `shown()`, `dismissed()`, `flipped()`, `contentLoaded()` |
|
|
54
82
|
|
|
55
|
-
|
|
83
|
+
Wire event adapters via `data-action`; call programmatic APIs directly from other controllers or outlets.
|
|
56
84
|
|
|
57
|
-
|
|
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" />
|
|
85
|
+
## Development
|
|
62
86
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
87
|
+
```bash
|
|
88
|
+
npm install
|
|
89
|
+
|
|
90
|
+
npm test # run all tests (Vitest)
|
|
91
|
+
npm run test:ui # Vitest UI
|
|
92
|
+
npm run test:coverage # coverage report
|
|
93
|
+
npm run lint # ESLint
|
|
94
|
+
npm run format:write # Prettier (write)
|
|
95
|
+
npm run build # build dist/
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
## Other Controllers
|
|
78
|
-
|
|
79
|
-
- `PopoverController` — show/hide content with optional remote loading
|
|
80
|
-
- `DismisserController` — click-outside dismissal
|
|
81
|
-
- `FlipperController` — element positioning
|
|
82
|
-
- `PannerController` — scroll management
|
|
83
|
-
|
|
84
98
|
## License
|
|
85
99
|
|
|
86
100
|
MIT © Ryan Chang
|
|
101
|
+
|
|
102
|
+
[npm_badge]: https://img.shields.io/npm/v/@stimulus-plumbers/controllers.svg
|
|
103
|
+
[npm]: https://www.npmjs.com/package/@stimulus-plumbers/controllers
|
|
104
|
+
[ci_badge]: https://github.com/ryancyq/stimulus-plumbers/actions/workflows/ci-stimulus.yml/badge.svg
|
|
105
|
+
[ci]: https://github.com/ryancyq/stimulus-plumbers/actions/workflows/ci-stimulus.yml
|