diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 000000000..932e75c45 --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,10 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.warnings = true +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js index 6671d28a4..5975c0789 100644 --- a/app/javascript/controllers/hello_controller.js +++ b/app/javascript/controllers/hello_controller.js @@ -1,18 +1,7 @@ -// Visit The Stimulus Handbook for more details -// https://stimulusjs.org/handbook/introduction -// -// This example controller works with specially annotated HTML like: -// -//
-//

-//
- -import { Controller } from "stimulus" +import { Controller } from "@hotwired/stimulus" export default class extends Controller { - static targets = [ "output" ] - connect() { - this.outputTarget.textContent = 'Hello, Stimulus!' + this.element.textContent = "Hello World!" } } diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index 6f53d84bb..c64575017 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -1,9 +1,7 @@ -// Load all the controllers within this directory and all subdirectories. -// Controller files must be named *_controller.js. +// This file is auto-generated by ./bin/rails stimulus:manifest:update +// Run that command whenever you add a new controller -import { Application } from "stimulus" -import { definitionsFromContext } from "stimulus/webpack-helpers" +import { application } from "./application" -const application = Application.start() -const context = require.context("controllers", true, /_controller\.js$/) -application.load(definitionsFromContext(context)) +import HelloController from "./hello_controller" +application.register("hello", HelloController) diff --git a/package.json b/package.json index 1bf8be47c..f044c889e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "data-collector", "private": true, "dependencies": { - "@hotwired/stimulus": "^3.0.0-beta.2", + "@hotwired/stimulus": "^3.0.0", "@hotwired/turbo": "^7.0.0-rc.3", "@hotwired/turbo-rails": "^7.0.0-rc.3", "@rails/actioncable": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 6a81d2821..dbbdda344 100644 --- a/yarn.lock +++ b/yarn.lock @@ -885,10 +885,10 @@ resolved "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz" integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw== -"@hotwired/stimulus@^3.0.0-beta.2": - version "3.0.0-beta.2" - resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.0.0-beta.2.tgz#64ca67af9cc473ca97bb99d98fee5bc08e4c3914" - integrity sha512-rp2XojlugD0mvqi3qbqM660PbjqS7hnq/8FYa7SK/DL2rvWDu0/Ka3KW8cyXtcB1RiVG4nX5Oh4oq3nmuDjENQ== +"@hotwired/stimulus@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.0.0.tgz#45171e61417af60f0e546665c52fae5b67295cee" + integrity sha512-UFIuuf7GjKJoIYromuTmqfzT8gZ8eu5zIB5m2QoEsopymGeN7rfDSTRPyRfwHIqP0x+0vWo4O1LFozw+/sWXxg== "@hotwired/turbo-rails@^7.0.0-rc.3": version "7.0.0-rc.3"