MCPcopy
hub / github.com/hotwired/stimulus

github.com/hotwired/stimulus @v3.2.2 sqlite

repository ↗ · DeepWiki ↗ · release v3.2.2 ↗
1,067 symbols 2,135 edges 112 files 0 documented · 0%
README

Stimulus Stimulus

A modest JavaScript framework for the HTML you already have

Stimulus is a JavaScript framework with modest ambitions. It doesn't seek to take over your entire front-end—in fact, it's not concerned with rendering HTML at all. Instead, it's designed to augment your HTML with just enough behavior to make it shine. Stimulus pairs beautifully with Turbo to provide a complete solution for fast, compelling applications with a minimal amount of effort.

How does it work? Sprinkle your HTML with controller, target, and action attributes:




  <input data-hello-target="name" type="text">

  <button data-action="click->hello#greet">Greet</button>

  <span data-hello-target="output"></span>



Then write a compatible controller. Stimulus brings it to life automatically:

// hello_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = [ "name", "output" ]

  greet() {
    this.outputTarget.textContent =
      `Hello, ${this.nameTarget.value}!`
  }
}

Stimulus continuously watches the page, kicking in as soon as attributes appear or disappear. It works with any update to the DOM, regardless of whether it comes from a full page load, a Turbo page change, or an Ajax request. Stimulus manages the whole lifecycle.

You can write your first controller in five minutes by following along in the Stimulus Handbook.

You can read more about why we created this new framework in The Origin of Stimulus.

Installing Stimulus

You can use Stimulus with any asset packaging systems. And if you prefer no build step at all, just drop a <script> tag on the page and get right down to business.

See the Installation Guide for detailed instructions.

Getting Help

Looking for the docs? Once you've read through the Handbook, consult the Stimulus Reference for API details.

Have a question about Stimulus? Connect with other Stimulus developers on the Hotwire Discourse community forum.

Contributing Back

Find a bug? Head over to our issue tracker and we'll do our best to help. We love pull requests, too!

We expect all Stimulus contributors to abide by the terms of our Code of Conduct.

Development

  • Fork the project locally
  • yarn install
  • yarn start - to run the local dev server with examples
  • yarn test - to run the unit tests
  • yarn lint - to run the linter with ESLint
  • yarn format - to format changes with Prettier

Acknowledgments

Stimulus is MIT-licensed open-source software from Basecamp, the creators of Ruby on Rails.

Continuous integration VMs generously provided by Sauce Labs.


© 2023 Basecamp, LLC.

Extension points exported contracts — how you extend this code

ErrorHandler (Interface)
(no doc) [7 implementers]
src/core/error_handler.ts
AttributeObserverDelegate (Interface)
(no doc) [6 implementers]
src/mutation-observers/attribute_observer.ts
Observer (Interface)
(no doc) [14 implementers]
src/tests/cases/observer_test_case.ts
BindingObserverDelegate (Interface)
(no doc) [3 implementers]
src/core/binding_observer.ts
TokenListObserverDelegate (Interface)
(no doc) [7 implementers]
src/mutation-observers/token_list_observer.ts
Value (Interface)
(no doc)
src/tests/modules/mutation-observers/value_list_observer_tests.ts
OutletObserverDelegate (Interface)
(no doc) [2 implementers]
src/core/outlet_observer.ts
ElementObserverDelegate (Interface)
(no doc) [4 implementers]
src/mutation-observers/element_observer.ts

Core symbols most depended-on inside this repo

findElement
called by 84
src/tests/cases/dom_test_case.ts
assertActions
called by 68
src/tests/cases/log_controller_test_case.ts
triggerEvent
called by 58
src/tests/cases/dom_test_case.ts
setAttribute
called by 41
src/tests/cases/dom_test_case.ts
defaultValueForDefinition
called by 33
src/core/value_properties.ts
get
called by 32
src/core/data_map.ts
get
called by 27
src/tests/modules/core/default_value_tests.ts
setAction
called by 26
src/tests/modules/core/event_options_tests.ts

Shape

Method 775
Class 188
Function 82
Interface 22

Languages

TypeScript100%

Modules by API surface

src/core/outlet_observer.ts38 symbols
src/tests/modules/core/event_options_tests.ts29 symbols
src/tests/modules/core/outlet_tests.ts28 symbols
src/mutation-observers/token_list_observer.ts26 symbols
src/mutation-observers/element_observer.ts25 symbols
src/tests/modules/core/default_value_tests.ts23 symbols
src/tests/modules/core/action_keyboard_filter_tests.ts22 symbols
src/tests/modules/core/value_tests.ts21 symbols
src/mutation-observers/selector_observer.ts21 symbols
src/core/router.ts21 symbols
src/mutation-observers/string_map_observer.ts20 symbols
src/core/value_properties.ts20 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@babel/core7.5.5 · 1×
@babel/plugin-proposal-class-properties7.5.5 · 1×
@babel/plugin-transform-runtime7.14.5 · 1×
@babel/preset-env7.5.5 · 1×
@hotwired/stimulus3.2.2 · 1×
@hotwired/stimulus-webpack-helpers1.0.0 · 1×
@hotwired/turbo7.2.4 · 1×
@rollup/plugin-node-resolve13.0.0 · 1×
@rollup/plugin-typescript11.1.1 · 1×
@types/qunit2.9.0 · 1×
@types/webpack-env1.14.0 · 1×
@typescript-eslint/eslint-plugin5.59.11 · 1×

For agents

$ claude mcp add stimulus \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact