turbo_ready 0.1.1 → 0.1.3

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.
@@ -1,7 +1,18 @@
1
1
  import invoke from './invoke'
2
2
 
3
- function initialize (streamActions) {
4
- streamActions.invoke = invoke
5
- }
3
+ if (!self['Turbo'])
4
+ throw new Error(
5
+ '`Turbo` is not defined! Be sure to import `turbo_ready` after `@hotwired/turbo` or `@hotwired/turbo-rails`.'
6
+ )
6
7
 
7
- export default { initialize }
8
+ if (!Turbo['StreamActions'])
9
+ throw new Error(
10
+ '`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.'
11
+ )
12
+
13
+ Turbo.StreamActions.invoke = invoke
14
+ self.TurboReady = { StreamActions: { invoke } }
15
+
16
+ console.info(
17
+ 'TurboReady has initialized and has registered new stream actions with Turbo.'
18
+ )
@@ -9,16 +9,11 @@ const textarea = /TEXTAREA/i
9
9
 
10
10
  function updating (el, toEl, childrenOnly, skip) {
11
11
  if (el.nodeType !== Node.ELEMENT_NODE) return
12
+ if (el !== document.activeElement) return
12
13
 
13
- let protect = false
14
- protect = el.tagName.match(textarea)
15
-
16
- if (protect) return skip()
17
-
18
- protect =
19
- el === document.activeElement &&
20
- el.tagName.match(input) &&
21
- el.getAttribute('type').match(inputTypes)
14
+ const protect =
15
+ el.tagName.match(textarea) ||
16
+ (el.tagName.match(input) && el.getAttribute('type').match(inputTypes))
22
17
 
23
18
  if (protect) return skip()
24
19
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboReady
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo_ready",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Take full control of the DOM with Turbo Streams",
5
5
  "main": "app/javascript/index.js",
6
6
  "repository": "https://github.com/hopsoft/turbo_ready",
@@ -10,14 +10,14 @@
10
10
  "@hotwired/turbo-rails": ">= 7.1"
11
11
  },
12
12
  "devDependencies": {
13
- "esbuild": "^0.15.5",
13
+ "esbuild": "^0.16.3",
14
14
  "eslint": "^8.19.0",
15
15
  "flowbite": "^1.5.3",
16
16
  "prettier-standard": "^16.4.1",
17
17
  "rustywind": "^0.15.1"
18
18
  },
19
19
  "scripts": {
20
- "build": "esbuild app/javascript/index.js --bundle --minify --sourcemap --format=esm --outfile=app/assets/builds/turbo_ready.js"
20
+ "build": "esbuild app/javascript/index.js --bundle --minify --sourcemap --format=esm --target=es2017 --analyze --outfile=app/assets/builds/turbo_ready.js"
21
21
  },
22
22
  "dependencies": {
23
23
  "@alpinejs/morph": ">=3.10.4",