stimulus_reflex 3.5.0.pre10 → 3.5.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of stimulus_reflex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/README.md +3 -3
- data/app/assets/javascripts/stimulus_reflex.js +319 -23
- data/app/assets/javascripts/stimulus_reflex.umd.js +316 -25
- data/app/channels/stimulus_reflex/channel.rb +1 -18
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +4 -10
- data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +1 -1
- data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +5 -0
- data/lib/install/development.rb +2 -2
- data/lib/install/importmap.rb +3 -3
- data/lib/stimulus_reflex/cable_ready_channels.rb +1 -0
- data/lib/stimulus_reflex/engine.rb +0 -4
- data/lib/stimulus_reflex/importmap.rb +3 -3
- data/lib/stimulus_reflex/installer.rb +2 -2
- data/lib/stimulus_reflex/reflex.rb +17 -8
- data/lib/stimulus_reflex/reflex_data.rb +6 -2
- data/lib/stimulus_reflex/reflex_factory.rb +2 -1
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/stimulus_reflex/version_checker.rb +54 -0
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +0 -2
- data/package.json +10 -8
- data/rollup.config.mjs +0 -19
- data/stimulus_reflex.gemspec +2 -2
- data/yarn.lock +173 -168
- metadata +15 -12
- data/app/assets/javascripts/stimulus_reflex.min.js +0 -2
- data/app/assets/javascripts/stimulus_reflex.min.js.map +0 -1
- data/app/assets/javascripts/stimulus_reflex.umd.min.js +0 -1065
- data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332456c0049281bf252fc97db164c2304a45b19b0087b5ca9cfc41288a8c7457
|
4
|
+
data.tar.gz: 5eed33fa8212d85f370167f91868cbc2b1c611daf66286cec0a5d1414136f889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 608f0f87a1910cc47df7a9e1a2b6a4f6169fc548e575c08ea1ed064a64582a026707a4d9e0898e340437d86957fed85bc0d3c727e3272b2d339a4fb74a5d44bb
|
7
|
+
data.tar.gz: 6c73096dd78ebd2801dddc6c421d21823bf87f51a513c7adcf0c2bfd72d0ebe360b914187ebb728155580a1136c533c4505ffb9f5ed232a7b237927f5ea6a9f9
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stimulus_reflex (3.5.0.
|
4
|
+
stimulus_reflex (3.5.0.rc2)
|
5
5
|
actioncable (>= 5.2, < 8)
|
6
6
|
actionpack (>= 5.2, < 8)
|
7
7
|
actionview (>= 5.2, < 8)
|
8
8
|
activesupport (>= 5.2, < 8)
|
9
|
-
cable_ready (>= 5.0.0.
|
9
|
+
cable_ready (>= 5.0.0.rc2)
|
10
10
|
nokogiri (~> 1.0)
|
11
|
-
rack (
|
11
|
+
rack (>= 2, < 4)
|
12
12
|
railties (>= 5.2, < 8)
|
13
13
|
redis (>= 4.0, < 6.0)
|
14
14
|
|
@@ -82,14 +82,14 @@ GEM
|
|
82
82
|
tzinfo (~> 2.0)
|
83
83
|
ast (2.4.2)
|
84
84
|
builder (3.2.4)
|
85
|
-
cable_ready (5.0.0.
|
85
|
+
cable_ready (5.0.0.rc2)
|
86
86
|
actionpack (>= 5.2)
|
87
87
|
actionview (>= 5.2)
|
88
88
|
activesupport (>= 5.2)
|
89
89
|
railties (>= 5.2)
|
90
90
|
thread-local (>= 1.1.0)
|
91
|
-
concurrent-ruby (1.2.
|
92
|
-
connection_pool (2.
|
91
|
+
concurrent-ruby (1.2.2)
|
92
|
+
connection_pool (2.4.0)
|
93
93
|
crass (1.0.6)
|
94
94
|
date (3.3.3)
|
95
95
|
erubi (1.12.0)
|
@@ -111,7 +111,7 @@ GEM
|
|
111
111
|
marcel (1.0.2)
|
112
112
|
method_source (1.0.0)
|
113
113
|
mini_mime (1.1.2)
|
114
|
-
minitest (5.
|
114
|
+
minitest (5.18.0)
|
115
115
|
mocha (1.13.0)
|
116
116
|
net-imap (0.3.4)
|
117
117
|
date
|
@@ -131,8 +131,8 @@ GEM
|
|
131
131
|
parser (3.2.1.0)
|
132
132
|
ast (~> 2.4.1)
|
133
133
|
racc (1.6.2)
|
134
|
-
rack (2.2.6.
|
135
|
-
rack-test (2.0
|
134
|
+
rack (2.2.6.4)
|
135
|
+
rack-test (2.1.0)
|
136
136
|
rack (>= 1.3)
|
137
137
|
rails (7.0.4.2)
|
138
138
|
actioncable (= 7.0.4.2)
|
@@ -164,7 +164,7 @@ GEM
|
|
164
164
|
rake (13.0.6)
|
165
165
|
redis (5.0.6)
|
166
166
|
redis-client (>= 0.9.0)
|
167
|
-
redis-client (0.
|
167
|
+
redis-client (0.14.0)
|
168
168
|
connection_pool
|
169
169
|
regexp_parser (2.7.0)
|
170
170
|
rexml (3.2.5)
|
data/README.md
CHANGED
@@ -84,7 +84,7 @@ Please note that we are not actively providing support on Stack Overflow. If you
|
|
84
84
|
|
85
85
|
## 🚀 Installation and upgrading
|
86
86
|
|
87
|
-
CLI and manual setup procedures are fully detailed in the [official docs](https://docs.stimulusreflex.com/setup).
|
87
|
+
CLI and manual setup procedures are fully detailed in the [official docs](https://docs.stimulusreflex.com/hello-world/setup.html).
|
88
88
|
|
89
89
|
### Rubygem
|
90
90
|
|
@@ -109,7 +109,7 @@ yarn add stimulus_reflex
|
|
109
109
|
|
110
110
|
# ...
|
111
111
|
|
112
|
-
pin 'stimulus_reflex', to: 'stimulus_reflex.
|
112
|
+
pin 'stimulus_reflex', to: 'stimulus_reflex.js', preload: true
|
113
113
|
```
|
114
114
|
|
115
115
|
#### Rails Asset pipeline (Sprockets):
|
@@ -117,7 +117,7 @@ pin 'stimulus_reflex', to: 'stimulus_reflex.min.js', preload: true
|
|
117
117
|
```html+erb
|
118
118
|
<!-- app/views/layouts/application.html.erb -->
|
119
119
|
|
120
|
-
<%= javascript_include_tag "stimulus_reflex.umd.
|
120
|
+
<%= javascript_include_tag "stimulus_reflex.umd.js", "data-turbo-track": "reload" %>
|
121
121
|
```
|
122
122
|
|
123
123
|
## 🙏 Contributing
|
@@ -1,8 +1,288 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus";
|
2
2
|
|
3
|
+
import CableReady, { Utils } from "cable_ready";
|
4
|
+
|
3
5
|
import { createConsumer } from "@rails/actioncable";
|
4
6
|
|
5
|
-
|
7
|
+
/*!
|
8
|
+
* Toastify js 1.12.0
|
9
|
+
* https://github.com/apvarun/toastify-js
|
10
|
+
* @license MIT licensed
|
11
|
+
*
|
12
|
+
* Copyright (C) 2018 Varun A P
|
13
|
+
*/ class Toastify {
|
14
|
+
defaults={
|
15
|
+
oldestFirst: true,
|
16
|
+
text: "Toastify is awesome!",
|
17
|
+
node: undefined,
|
18
|
+
duration: 3e3,
|
19
|
+
selector: undefined,
|
20
|
+
callback: function() {},
|
21
|
+
destination: undefined,
|
22
|
+
newWindow: false,
|
23
|
+
close: false,
|
24
|
+
gravity: "toastify-top",
|
25
|
+
positionLeft: false,
|
26
|
+
position: "",
|
27
|
+
backgroundColor: "",
|
28
|
+
avatar: "",
|
29
|
+
className: "",
|
30
|
+
stopOnFocus: true,
|
31
|
+
onClick: function() {},
|
32
|
+
offset: {
|
33
|
+
x: 0,
|
34
|
+
y: 0
|
35
|
+
},
|
36
|
+
escapeMarkup: true,
|
37
|
+
ariaLive: "polite",
|
38
|
+
style: {
|
39
|
+
background: ""
|
40
|
+
}
|
41
|
+
};
|
42
|
+
constructor(options) {
|
43
|
+
this.version = "1.12.0";
|
44
|
+
this.options = {};
|
45
|
+
this.toastElement = null;
|
46
|
+
this._rootElement = document.body;
|
47
|
+
this._init(options);
|
48
|
+
}
|
49
|
+
showToast() {
|
50
|
+
this.toastElement = this._buildToast();
|
51
|
+
if (typeof this.options.selector === "string") {
|
52
|
+
this._rootElement = document.getElementById(this.options.selector);
|
53
|
+
} else if (this.options.selector instanceof HTMLElement || this.options.selector instanceof ShadowRoot) {
|
54
|
+
this._rootElement = this.options.selector;
|
55
|
+
} else {
|
56
|
+
this._rootElement = document.body;
|
57
|
+
}
|
58
|
+
if (!this._rootElement) {
|
59
|
+
throw "Root element is not defined";
|
60
|
+
}
|
61
|
+
this._rootElement.insertBefore(this.toastElement, this._rootElement.firstChild);
|
62
|
+
this._reposition();
|
63
|
+
if (this.options.duration > 0) {
|
64
|
+
this.toastElement.timeOutValue = window.setTimeout((() => {
|
65
|
+
this._removeElement(this.toastElement);
|
66
|
+
}), this.options.duration);
|
67
|
+
}
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
hideToast() {
|
71
|
+
if (this.toastElement.timeOutValue) {
|
72
|
+
clearTimeout(this.toastElement.timeOutValue);
|
73
|
+
}
|
74
|
+
this._removeElement(this.toastElement);
|
75
|
+
}
|
76
|
+
_init(options) {
|
77
|
+
this.options = Object.assign(this.defaults, options);
|
78
|
+
if (this.options.backgroundColor) {
|
79
|
+
console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
|
80
|
+
}
|
81
|
+
this.toastElement = null;
|
82
|
+
this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : "toastify-top";
|
83
|
+
this.options.stopOnFocus = options.stopOnFocus === undefined ? true : options.stopOnFocus;
|
84
|
+
if (options.backgroundColor) {
|
85
|
+
this.options.style.background = options.backgroundColor;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
_buildToast() {
|
89
|
+
if (!this.options) {
|
90
|
+
throw "Toastify is not initialized";
|
91
|
+
}
|
92
|
+
let divElement = document.createElement("div");
|
93
|
+
divElement.className = `toastify on ${this.options.className}`;
|
94
|
+
divElement.className += ` toastify-${this.options.position}`;
|
95
|
+
divElement.className += ` ${this.options.gravity}`;
|
96
|
+
for (const property in this.options.style) {
|
97
|
+
divElement.style[property] = this.options.style[property];
|
98
|
+
}
|
99
|
+
if (this.options.ariaLive) {
|
100
|
+
divElement.setAttribute("aria-live", this.options.ariaLive);
|
101
|
+
}
|
102
|
+
if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
|
103
|
+
divElement.appendChild(this.options.node);
|
104
|
+
} else {
|
105
|
+
if (this.options.escapeMarkup) {
|
106
|
+
divElement.innerText = this.options.text;
|
107
|
+
} else {
|
108
|
+
divElement.innerHTML = this.options.text;
|
109
|
+
}
|
110
|
+
if (this.options.avatar !== "") {
|
111
|
+
let avatarElement = document.createElement("img");
|
112
|
+
avatarElement.src = this.options.avatar;
|
113
|
+
avatarElement.className = "toastify-avatar";
|
114
|
+
if (this.options.position == "left") {
|
115
|
+
divElement.appendChild(avatarElement);
|
116
|
+
} else {
|
117
|
+
divElement.insertAdjacentElement("afterbegin", avatarElement);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
if (this.options.close === true) {
|
122
|
+
let closeElement = document.createElement("button");
|
123
|
+
closeElement.type = "button";
|
124
|
+
closeElement.setAttribute("aria-label", "Close");
|
125
|
+
closeElement.className = "toast-close";
|
126
|
+
closeElement.innerHTML = "✖";
|
127
|
+
closeElement.addEventListener("click", (event => {
|
128
|
+
event.stopPropagation();
|
129
|
+
this._removeElement(this.toastElement);
|
130
|
+
window.clearTimeout(this.toastElement.timeOutValue);
|
131
|
+
}));
|
132
|
+
const width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
133
|
+
if (this.options.position == "left" && width > 360) {
|
134
|
+
divElement.insertAdjacentElement("afterbegin", closeElement);
|
135
|
+
} else {
|
136
|
+
divElement.appendChild(closeElement);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
if (this.options.stopOnFocus && this.options.duration > 0) {
|
140
|
+
divElement.addEventListener("mouseover", (event => {
|
141
|
+
window.clearTimeout(divElement.timeOutValue);
|
142
|
+
}));
|
143
|
+
divElement.addEventListener("mouseleave", (() => {
|
144
|
+
divElement.timeOutValue = window.setTimeout((() => {
|
145
|
+
this._removeElement(divElement);
|
146
|
+
}), this.options.duration);
|
147
|
+
}));
|
148
|
+
}
|
149
|
+
if (typeof this.options.destination !== "undefined") {
|
150
|
+
divElement.addEventListener("click", (event => {
|
151
|
+
event.stopPropagation();
|
152
|
+
if (this.options.newWindow === true) {
|
153
|
+
window.open(this.options.destination, "_blank");
|
154
|
+
} else {
|
155
|
+
window.location = this.options.destination;
|
156
|
+
}
|
157
|
+
}));
|
158
|
+
}
|
159
|
+
if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
|
160
|
+
divElement.addEventListener("click", (event => {
|
161
|
+
event.stopPropagation();
|
162
|
+
this.options.onClick();
|
163
|
+
}));
|
164
|
+
}
|
165
|
+
if (typeof this.options.offset === "object") {
|
166
|
+
const x = this._getAxisOffsetAValue("x", this.options);
|
167
|
+
const y = this._getAxisOffsetAValue("y", this.options);
|
168
|
+
const xOffset = this.options.position == "left" ? x : `-${x}`;
|
169
|
+
const yOffset = this.options.gravity == "toastify-top" ? y : `-${y}`;
|
170
|
+
divElement.style.transform = `translate(${xOffset},${yOffset})`;
|
171
|
+
}
|
172
|
+
return divElement;
|
173
|
+
}
|
174
|
+
_removeElement(toastElement) {
|
175
|
+
toastElement.className = toastElement.className.replace(" on", "");
|
176
|
+
window.setTimeout((() => {
|
177
|
+
if (this.options.node && this.options.node.parentNode) {
|
178
|
+
this.options.node.parentNode.removeChild(this.options.node);
|
179
|
+
}
|
180
|
+
if (toastElement.parentNode) {
|
181
|
+
toastElement.parentNode.removeChild(toastElement);
|
182
|
+
}
|
183
|
+
this.options.callback.call(toastElement);
|
184
|
+
this._reposition();
|
185
|
+
}), 400);
|
186
|
+
}
|
187
|
+
_reposition() {
|
188
|
+
let topLeftOffsetSize = {
|
189
|
+
top: 15,
|
190
|
+
bottom: 15
|
191
|
+
};
|
192
|
+
let topRightOffsetSize = {
|
193
|
+
top: 15,
|
194
|
+
bottom: 15
|
195
|
+
};
|
196
|
+
let offsetSize = {
|
197
|
+
top: 15,
|
198
|
+
bottom: 15
|
199
|
+
};
|
200
|
+
let allToasts = this._rootElement.querySelectorAll(".toastify");
|
201
|
+
let classUsed;
|
202
|
+
for (let i = 0; i < allToasts.length; i++) {
|
203
|
+
if (allToasts[i].classList.contains("toastify-top") === true) {
|
204
|
+
classUsed = "toastify-top";
|
205
|
+
} else {
|
206
|
+
classUsed = "toastify-bottom";
|
207
|
+
}
|
208
|
+
let height = allToasts[i].offsetHeight;
|
209
|
+
classUsed = classUsed.substr(9, classUsed.length - 1);
|
210
|
+
let offset = 15;
|
211
|
+
let width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
212
|
+
if (width <= 360) {
|
213
|
+
allToasts[i].style[classUsed] = `${offsetSize[classUsed]}px`;
|
214
|
+
offsetSize[classUsed] += height + offset;
|
215
|
+
} else {
|
216
|
+
if (allToasts[i].classList.contains("toastify-left") === true) {
|
217
|
+
allToasts[i].style[classUsed] = `${topLeftOffsetSize[classUsed]}px`;
|
218
|
+
topLeftOffsetSize[classUsed] += height + offset;
|
219
|
+
} else {
|
220
|
+
allToasts[i].style[classUsed] = `${topRightOffsetSize[classUsed]}px`;
|
221
|
+
topRightOffsetSize[classUsed] += height + offset;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
_getAxisOffsetAValue(axis, options) {
|
227
|
+
if (options.offset[axis]) {
|
228
|
+
if (isNaN(options.offset[axis])) {
|
229
|
+
return options.offset[axis];
|
230
|
+
} else {
|
231
|
+
return `${options.offset[axis]}px`;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
return "0px";
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
function StartToastifyInstance(options) {
|
239
|
+
return new Toastify(options);
|
240
|
+
}
|
241
|
+
|
242
|
+
CableReady.operations.stimulusReflexVersionMismatch = operation => {
|
243
|
+
const levels = {
|
244
|
+
info: {},
|
245
|
+
success: {
|
246
|
+
background: "#198754",
|
247
|
+
color: "white"
|
248
|
+
},
|
249
|
+
warn: {
|
250
|
+
background: "#ffc107",
|
251
|
+
color: "black"
|
252
|
+
},
|
253
|
+
error: {
|
254
|
+
background: "#dc3545",
|
255
|
+
color: "white"
|
256
|
+
}
|
257
|
+
};
|
258
|
+
const defaults = {
|
259
|
+
selector: setupToastify(),
|
260
|
+
close: true,
|
261
|
+
duration: 30 * 1e3,
|
262
|
+
gravity: "bottom",
|
263
|
+
position: "right",
|
264
|
+
newWindow: true,
|
265
|
+
style: levels[operation.level || "info"]
|
266
|
+
};
|
267
|
+
StartToastifyInstance({
|
268
|
+
...defaults,
|
269
|
+
...operation
|
270
|
+
}).showToast();
|
271
|
+
};
|
272
|
+
|
273
|
+
function setupToastify() {
|
274
|
+
const id = "stimulus-reflex-toast-element";
|
275
|
+
let element = document.querySelector(`#${id}`);
|
276
|
+
if (!element) {
|
277
|
+
element = document.createElement("div");
|
278
|
+
element.id = id;
|
279
|
+
document.documentElement.appendChild(element);
|
280
|
+
const styles = document.createElement("style");
|
281
|
+
styles.innerHTML = `\n #${id} .toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n bottom: -150px;\n right: 15px;\n }\n\n #${id} .toastify.on {\n opacity: 1;\n }\n\n #${id} .toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n }\n `;
|
282
|
+
document.head.appendChild(styles);
|
283
|
+
}
|
284
|
+
return element;
|
285
|
+
}
|
6
286
|
|
7
287
|
let deprecationWarnings = true;
|
8
288
|
|
@@ -170,6 +450,8 @@ const getReflexRoots = element => {
|
|
170
450
|
return list;
|
171
451
|
};
|
172
452
|
|
453
|
+
const reflexNameToControllerIdentifier = reflexName => reflexName.replace(/([a-z0–9])([A-Z])/g, "$1-$2").replace(/(::)/g, "--").replace(/-reflex$/gi, "").toLowerCase();
|
454
|
+
|
173
455
|
const stages = [ "created", "before", "delivered", "queued", "after", "finalized", "success", "error", "halted", "forbidden" ];
|
174
456
|
|
175
457
|
let lastReflex;
|
@@ -326,8 +608,15 @@ class Reflex {
|
|
326
608
|
|
327
609
|
const received = data => {
|
328
610
|
if (!data.cableReady) return;
|
329
|
-
if (data.version.replace(".pre", "-pre") !== CableReady.version) {
|
330
|
-
|
611
|
+
if (data.version.replace(".pre", "-pre").replace(".rc", "-rc") !== CableReady.version) {
|
612
|
+
const mismatch = `CableReady failed to execute your reflex action due to a version mismatch between your gem and JavaScript version. Package versions must match exactly.\n\ncable_ready gem: ${data.version}\ncable_ready npm: ${CableReady.version}`;
|
613
|
+
console.error(mismatch);
|
614
|
+
if (Debug$1.enabled) {
|
615
|
+
CableReady.operations.stimulusReflexVersionMismatch({
|
616
|
+
text: mismatch,
|
617
|
+
level: "error"
|
618
|
+
});
|
619
|
+
}
|
331
620
|
return;
|
332
621
|
}
|
333
622
|
let reflexOperations = [];
|
@@ -656,7 +945,7 @@ const extractDataAttributes = element => {
|
|
656
945
|
|
657
946
|
var name = "stimulus_reflex";
|
658
947
|
|
659
|
-
var version = "3.5.0-
|
948
|
+
var version = "3.5.0-rc2";
|
660
949
|
|
661
950
|
var description = "Build reactive applications with the Rails tooling you already know and love.";
|
662
951
|
|
@@ -693,8 +982,9 @@ var scripts = {
|
|
693
982
|
"build:watch": "yarn rollup -wc",
|
694
983
|
watch: "yarn build:watch",
|
695
984
|
test: "web-test-runner javascript/test/**/*.test.js",
|
985
|
+
"test:watch": "yarn test --watch",
|
696
986
|
"docs:dev": "vitepress dev docs",
|
697
|
-
"docs:build": "vitepress build docs",
|
987
|
+
"docs:build": "vitepress build docs && cp docs/_redirects docs/.vitepress/dist",
|
698
988
|
"docs:preview": "vitepress preview docs"
|
699
989
|
};
|
700
990
|
|
@@ -703,9 +993,9 @@ var peerDependencies = {
|
|
703
993
|
};
|
704
994
|
|
705
995
|
var dependencies = {
|
706
|
-
"@hotwired/stimulus": "
|
707
|
-
"@rails/actioncable": "
|
708
|
-
cable_ready: "5.0.0-
|
996
|
+
"@hotwired/stimulus": "^3",
|
997
|
+
"@rails/actioncable": "^6 || ^7",
|
998
|
+
cable_ready: "5.0.0-rc2"
|
709
999
|
};
|
710
1000
|
|
711
1001
|
var devDependencies = {
|
@@ -715,10 +1005,11 @@ var devDependencies = {
|
|
715
1005
|
"@rollup/plugin-terser": "^0.4.0",
|
716
1006
|
"@web/dev-server-esbuild": "^0.3.3",
|
717
1007
|
"@web/dev-server-rollup": "^0.3.21",
|
718
|
-
"@web/test-runner": "^0.15.
|
1008
|
+
"@web/test-runner": "^0.15.1",
|
719
1009
|
"prettier-standard": "^16.4.1",
|
720
|
-
rollup: "^3.
|
721
|
-
|
1010
|
+
rollup: "^3.19.1",
|
1011
|
+
"toastify-js": "^1.12.0",
|
1012
|
+
vitepress: "^1.0.0-alpha.56"
|
722
1013
|
};
|
723
1014
|
|
724
1015
|
var packageInfo = {
|
@@ -948,11 +1239,11 @@ const error = (reflex, event) => {
|
|
948
1239
|
})));
|
949
1240
|
};
|
950
1241
|
|
951
|
-
const localReflexControllers = element =>
|
952
|
-
const
|
953
|
-
|
954
|
-
return
|
955
|
-
}
|
1242
|
+
const localReflexControllers = element => {
|
1243
|
+
const potentialIdentifiers = attributeValues(element.getAttribute(Schema.controller));
|
1244
|
+
const potentialControllers = potentialIdentifiers.map((identifier => App.app.getControllerForElementAndIdentifier(element, identifier)));
|
1245
|
+
return potentialControllers.filter((controller => controller && controller.StimulusReflex));
|
1246
|
+
};
|
956
1247
|
|
957
1248
|
const allReflexControllers = element => {
|
958
1249
|
let controllers = [];
|
@@ -965,8 +1256,9 @@ const allReflexControllers = element => {
|
|
965
1256
|
|
966
1257
|
const findControllerByReflexName = (reflexName, controllers) => {
|
967
1258
|
const controller = controllers.find((controller => {
|
968
|
-
if (!controller.identifier) return;
|
969
|
-
|
1259
|
+
if (!controller || !controller.identifier) return;
|
1260
|
+
const identifier = reflexNameToControllerIdentifier(extractReflexName(reflexName));
|
1261
|
+
return identifier === controller.identifier;
|
970
1262
|
}));
|
971
1263
|
return controller || controllers[0];
|
972
1264
|
};
|
@@ -976,18 +1268,22 @@ const scanForReflexes = debounce((() => {
|
|
976
1268
|
reflexElements.forEach((element => scanForReflexesOnElement(element)));
|
977
1269
|
}), 20);
|
978
1270
|
|
979
|
-
const scanForReflexesOnElement = element => {
|
1271
|
+
const scanForReflexesOnElement = (element, controller = null) => {
|
980
1272
|
const controllerAttribute = element.getAttribute(Schema.controller);
|
981
|
-
const controllers = attributeValues(controllerAttribute);
|
1273
|
+
const controllers = attributeValues(controllerAttribute).filter((controller => controller !== "stimulus-reflex"));
|
982
1274
|
const reflexAttribute = element.getAttribute(Schema.reflex);
|
983
1275
|
const reflexAttributeNames = attributeValues(reflexAttribute);
|
984
1276
|
const actionAttribute = element.getAttribute(Schema.action);
|
985
1277
|
const actions = attributeValues(actionAttribute).filter((action => !action.includes("#__perform")));
|
986
1278
|
reflexAttributeNames.forEach((reflexName => {
|
987
|
-
const
|
1279
|
+
const potentialControllers = [ controller ].concat(allReflexControllers(element));
|
1280
|
+
controller = findControllerByReflexName(reflexName, potentialControllers);
|
988
1281
|
const controllerName = controller ? controller.identifier : "stimulus-reflex";
|
989
1282
|
actions.push(`${reflexName.split("->")[0]}->${controllerName}#__perform`);
|
990
|
-
|
1283
|
+
const parentControllerElement = element.closest(`[data-controller~=${controllerName}]`);
|
1284
|
+
if (!parentControllerElement) {
|
1285
|
+
controllers.push(controllerName);
|
1286
|
+
}
|
991
1287
|
}));
|
992
1288
|
const controllerValue = attributeValue(controllers);
|
993
1289
|
const actionValue = attributeValue(actions);
|
@@ -1114,7 +1410,7 @@ const register = (controller, options = {}) => {
|
|
1114
1410
|
});
|
1115
1411
|
}
|
1116
1412
|
});
|
1117
|
-
scanForReflexesOnElement(controller.element);
|
1413
|
+
scanForReflexesOnElement(controller.element, controller);
|
1118
1414
|
emitEvent("stimulus-reflex:controller-registered", {
|
1119
1415
|
detail: {
|
1120
1416
|
controller: controller
|