turbo_reflex 0.0.27 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -18
- data/README.md +1 -1
- data/app/assets/builds/turbo_reflex.js +6 -1
- data/app/assets/builds/turbo_reflex.js.map +4 -4
- data/app/javascript/index.js +4 -1
- data/app/javascript/state/index.js +11 -20
- data/lib/turbo_reflex/version.rb +1 -1
- data/package.json +7 -5
- data/tags +17627 -2055
- data/turbo_reflex.gemspec +1 -1
- data/yarn.lock +189 -157
- metadata +4 -4
data/app/javascript/index.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import 'turbo_ready'
|
1
2
|
import './turbo'
|
2
3
|
import schema from './schema'
|
3
4
|
import { dispatch, allEvents as events } from './events'
|
@@ -74,7 +75,7 @@ delegates.register('change', [
|
|
74
75
|
delegates.register('submit', [`form[${schema.reflexAttribute}]`])
|
75
76
|
delegates.register('click', [`[${schema.reflexAttribute}]`])
|
76
77
|
|
77
|
-
|
78
|
+
self.TurboReflex = {
|
78
79
|
logger,
|
79
80
|
schema,
|
80
81
|
registerEventDelegate: delegates.register,
|
@@ -92,3 +93,5 @@ export default self.TurboReflex = {
|
|
92
93
|
return state.delta
|
93
94
|
}
|
94
95
|
}
|
96
|
+
|
97
|
+
export default self.TurboReflex
|
@@ -3,9 +3,10 @@ import observable from './observable'
|
|
3
3
|
import { dispatch, stateEvents as events } from '../events'
|
4
4
|
|
5
5
|
let loadedState, currentState, changedState
|
6
|
-
let
|
6
|
+
let loadStateTimeout
|
7
7
|
|
8
8
|
function loadState () {
|
9
|
+
if (!meta.element) return loadStateLater()
|
9
10
|
const json = atob(meta.element.dataset.state)
|
10
11
|
changedState = {}
|
11
12
|
currentState = observable(JSON.parse(json))
|
@@ -16,28 +17,18 @@ function loadState () {
|
|
16
17
|
)
|
17
18
|
}
|
18
19
|
|
19
|
-
function
|
20
|
-
|
21
|
-
|
22
|
-
if (m.attributeName === 'data-state') loadState()
|
23
|
-
})
|
20
|
+
function loadStateLater () {
|
21
|
+
clearTimeout(loadStateTimeout)
|
22
|
+
loadStateTimeout = setTimeout(loadState, 10)
|
24
23
|
}
|
25
24
|
|
26
|
-
|
27
|
-
if (observer) return
|
28
|
-
observer = new MutationObserver(metaMutated)
|
29
|
-
observer.observe(meta.element, { attributes: true })
|
30
|
-
}
|
25
|
+
if (!loadedState) loadState()
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
addEventListener('DOMContentLoaded', initObserver)
|
38
|
-
}
|
39
|
-
addEventListener('turbo:load', initObserver)
|
40
|
-
addEventListener('turbo:frame-load', initObserver)
|
27
|
+
addEventListener('DOMContentLoaded', loadStateLater)
|
28
|
+
addEventListener('load', loadStateLater)
|
29
|
+
addEventListener('turbo:load', loadStateLater)
|
30
|
+
addEventListener('turbo:frame-load', loadStateLater)
|
31
|
+
addEventListener('turbo-reflex:success', loadStateLater)
|
41
32
|
|
42
33
|
addEventListener(events.stateChange, event => {
|
43
34
|
changedState = {}
|
data/lib/turbo_reflex/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
{
|
2
2
|
"name": "turbo_reflex",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.28",
|
4
4
|
"description": "Reflexes for Turbo Frames that help you build robust reactive applications",
|
5
5
|
"main": "app/javascript/index.js",
|
6
6
|
"repository": "https://github.com/hopsoft/turbo_reflex",
|
7
7
|
"author": "Nate Hopkins (hopsoft) <natehop@gmail.com>",
|
8
8
|
"license": "MIT",
|
9
|
+
"dependencies": {
|
10
|
+
"turbo_ready": ">= 0.1.3"
|
11
|
+
},
|
9
12
|
"peerDependencies": {
|
10
|
-
"@hotwired/turbo-rails": ">= 7.
|
11
|
-
"turbo_ready": ">= 0.1"
|
13
|
+
"@hotwired/turbo-rails": ">= 7.2.0"
|
12
14
|
},
|
13
15
|
"devDependencies": {
|
14
|
-
"esbuild": "^0.
|
16
|
+
"esbuild": "^0.16.3",
|
15
17
|
"eslint": "^8.19.0",
|
16
18
|
"flowbite": "^1.5.3",
|
17
19
|
"prettier-standard": "^16.4.1",
|
18
20
|
"rustywind": "^0.15.1"
|
19
21
|
},
|
20
22
|
"scripts": {
|
21
|
-
"build": "esbuild app/javascript/index.js --bundle --minify --sourcemap --format=esm --outfile=app/assets/builds/turbo_reflex.js"
|
23
|
+
"build": "esbuild app/javascript/index.js --bundle --minify --sourcemap --format=esm --target=es2017 --analyze --outfile=app/assets/builds/turbo_reflex.js"
|
22
24
|
}
|
23
25
|
}
|