ariadne_view_components 0.0.86.6 → 0.0.86.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/javascripts/ariadne_view_components.js +12 -12
- data/app/assets/javascripts/ariadne_view_components.js.br +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.gz +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/components/ariadne/form/toggle/component.rb +9 -4
- data/app/components/ariadne/form/toggle/component.ts +16 -4
- data/app/components/ariadne/ui/accordion/component.ts +12 -4
- data/app/components/ariadne/ui/combobox/component.ts +2 -3
- data/app/components/ariadne/ui/list/component.ts +1 -1
- data/app/components/ariadne/ui/overlay/component.ts +1 -1
- data/app/components/ariadne/ui/time_ago/component.ts +1 -3
- data/lib/ariadne/view_components/version.rb +1 -1
- metadata +2 -2
@@ -10,12 +10,14 @@ module Ariadne
|
|
10
10
|
|
11
11
|
include Ariadne::Behaviors::Tooltipable
|
12
12
|
|
13
|
-
# @param form_url [String] The URL to
|
14
|
-
# @param
|
13
|
+
# @param form_url [String] The URL to submit to when the toggle switch is toggled. If `nil`, the toggle switch will not make any requests.
|
14
|
+
# @param form_method [String] A HTTP method to use.
|
15
|
+
# @param turbo [Boolean] Whether or not to request a turbo stream and render the response as such.
|
15
16
|
# @param checked [Boolean] Whether the toggle switch is on or off.
|
16
17
|
# @param enabled [Boolean] Whether or not the toggle switch responds to user input.
|
17
18
|
option :form_url, default: proc { nil }
|
18
19
|
option :form_method, default: proc { :post }
|
20
|
+
option :turbo, default: proc { false }
|
19
21
|
option :checked, default: proc { false }
|
20
22
|
option :enabled, default: proc { true }
|
21
23
|
|
@@ -28,10 +30,12 @@ module Ariadne
|
|
28
30
|
end
|
29
31
|
|
30
32
|
html_attrs[:data] ||= {}
|
33
|
+
added_controller = html_attrs[:data].delete(:controller) || ""
|
34
|
+
added_action = html_attrs[:data].delete(:action) || ""
|
31
35
|
html_attrs[:data] = {
|
32
|
-
controller: "#{stimulus_name} #{
|
36
|
+
controller: "#{stimulus_name} #{added_controller}",
|
33
37
|
"#{stimulus_name}-target": "toggle",
|
34
|
-
action: "click->#{stimulus_name}#toggle #{
|
38
|
+
action: "click->#{stimulus_name}#toggle #{added_action}",
|
35
39
|
}.merge(html_attrs[:data])
|
36
40
|
end
|
37
41
|
|
@@ -50,6 +54,7 @@ module Ariadne
|
|
50
54
|
"#{stimulus_name}-csrf-token-value": csrf_token,
|
51
55
|
"#{stimulus_name}-form-method-value": @form_method,
|
52
56
|
"#{stimulus_name}-form-url-value": @form_url,
|
57
|
+
"#{stimulus_name}-turbo-value": @turbo,
|
53
58
|
}
|
54
59
|
html_attrs[:data] = html_attrs[:data].merge(form_values)
|
55
60
|
end
|
@@ -8,6 +8,7 @@ export default class ToggleController extends controllerFactory<HTMLInputElement
|
|
8
8
|
formMethod: String,
|
9
9
|
formUrl: String,
|
10
10
|
csrfToken: String,
|
11
|
+
turbo: Boolean,
|
11
12
|
},
|
12
13
|
}) {
|
13
14
|
connect() {
|
@@ -104,22 +105,33 @@ export default class ToggleController extends controllerFactory<HTMLInputElement
|
|
104
105
|
|
105
106
|
let response
|
106
107
|
|
108
|
+
const requestHeaders: {[key: string]: string} = {
|
109
|
+
'Requested-With': 'XMLHttpRequest',
|
110
|
+
}
|
111
|
+
|
112
|
+
if (this.turboValue) {
|
113
|
+
requestHeaders['Accept'] = 'text/vnd.turbo-stream.html'
|
114
|
+
}
|
115
|
+
|
107
116
|
try {
|
108
117
|
response = await fetch(this.formUrlValue, {
|
109
118
|
credentials: 'same-origin',
|
110
119
|
method: this.formMethodValue,
|
111
|
-
headers:
|
112
|
-
'Requested-With': 'XMLHttpRequest',
|
113
|
-
},
|
120
|
+
headers: requestHeaders,
|
114
121
|
body,
|
115
122
|
})
|
116
123
|
} catch (error) {
|
117
|
-
throw new Error(
|
124
|
+
throw new Error(`A network error occurred, please try again: ${error.message}`)
|
118
125
|
}
|
119
126
|
|
120
127
|
if (!response.ok) {
|
121
128
|
throw new Error(await response.text())
|
122
129
|
}
|
130
|
+
|
131
|
+
const contentType = response.headers.get('Content-Type')
|
132
|
+
if (window.Turbo && this.turbo && contentType?.startsWith('text/vnd.turbo-stream.html')) {
|
133
|
+
window.Turbo.renderStreamMessage(await response.text())
|
134
|
+
}
|
123
135
|
}
|
124
136
|
|
125
137
|
// the authenticity token is passed into the element and is not generated in js land
|
@@ -13,7 +13,11 @@ export default class Controller extends controllerFactory()({
|
|
13
13
|
connect() {
|
14
14
|
// Set the initial state of the accordion
|
15
15
|
this.animationDurationValue = 0.15
|
16
|
-
this.openValue
|
16
|
+
if (this.openValue) {
|
17
|
+
this.open()
|
18
|
+
} else {
|
19
|
+
this.close()
|
20
|
+
}
|
17
21
|
}
|
18
22
|
|
19
23
|
// Toggle the 'open' value
|
@@ -22,7 +26,7 @@ export default class Controller extends controllerFactory()({
|
|
22
26
|
}
|
23
27
|
|
24
28
|
// Handle changes in the 'open' value
|
25
|
-
openValueChanged(isOpen
|
29
|
+
openValueChanged(isOpen) {
|
26
30
|
if (isOpen) {
|
27
31
|
this.open()
|
28
32
|
} else {
|
@@ -34,7 +38,9 @@ export default class Controller extends controllerFactory()({
|
|
34
38
|
open() {
|
35
39
|
if (this.hasContentTarget) {
|
36
40
|
this.revealContent()
|
37
|
-
this.hasIconTarget
|
41
|
+
if (this.hasIconTarget) {
|
42
|
+
this.rotateIcon()
|
43
|
+
}
|
38
44
|
this.openValue = true
|
39
45
|
}
|
40
46
|
}
|
@@ -42,7 +48,9 @@ export default class Controller extends controllerFactory()({
|
|
42
48
|
close() {
|
43
49
|
if (this.hasContentTarget) {
|
44
50
|
this.hideContent()
|
45
|
-
this.hasIconTarget
|
51
|
+
if (this.hasIconTarget) {
|
52
|
+
this.rotateIcon()
|
53
|
+
}
|
46
54
|
this.openValue = false
|
47
55
|
}
|
48
56
|
}
|
@@ -108,9 +108,8 @@ export default class ComboboxController extends controllerFactory<HTMLDetailsEle
|
|
108
108
|
|
109
109
|
const selectedText = (checkedRadioButton.labels?.item(0) as HTMLLabelElement).textContent
|
110
110
|
|
111
|
-
this.buttonTarget.querySelector(
|
112
|
-
|
113
|
-
).textContent = `${this.dynamicLabelPrefixValue}${selectedText}`
|
111
|
+
this.buttonTarget.querySelector('[data-ariadne-ui-button-target="content"]').textContent =
|
112
|
+
`${this.dynamicLabelPrefixValue}${selectedText}`
|
114
113
|
}
|
115
114
|
|
116
115
|
toggle(): void {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {type Placement, autoUpdate, computePosition, flip, offset, shift
|
1
|
+
import {type Placement, autoUpdate, computePosition, flip, offset, shift} from '@floating-ui/dom'
|
2
2
|
import {controllerFactory} from '@utils/createController'
|
3
3
|
import {useClickOutside, useMutation} from 'stimulus-use'
|
4
4
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ariadne_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.86.
|
4
|
+
version: 0.0.86.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tailwind_merge
|