bard-tag_field 0.2.0 → 0.4.0
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/app/assets/javascripts/input-tag.js +17 -2
- data/lib/bard/tag_field/cucumber.rb +77 -0
- data/lib/bard/tag_field/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2710ff20fb473cf6eef8319d72f88cf59b0f3c24cca66badbad936f644df368b
|
4
|
+
data.tar.gz: e16029c932fc9329796d05b587dd8a5697d59a99a0db9692f15c8b37bfaa04c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5694eb901dd9ce23e13b1685da503150c3adbf7fb102124b7c9c3f7114dfffaeb56e6f8d000606e96172f2ae21193a8d8eb47c7e2c1cb625f4579c38271321a3
|
7
|
+
data.tar.gz: b812a1d58f7280aca270133b0b6ff372b0d406c9122fd7b42a5ec17073104baf6a0242000cedc9075f5f8a9a9f29c24ff30f2f5dc060a0b20c17e2445a655099
|
@@ -1147,10 +1147,25 @@ class InputTag extends HTMLElement {
|
|
1147
1147
|
}
|
1148
1148
|
|
1149
1149
|
get value() {
|
1150
|
-
|
1150
|
+
const internalValue = this._internals.value;
|
1151
|
+
if (this.hasAttribute('multiple')) {
|
1152
|
+
return internalValue; // Return array for multiple mode
|
1153
|
+
} else {
|
1154
|
+
return internalValue.length > 0 ? internalValue[0] : ''; // Return string for single mode
|
1155
|
+
}
|
1151
1156
|
}
|
1152
1157
|
|
1153
|
-
set value(
|
1158
|
+
set value(input) {
|
1159
|
+
// Convert input to array format for internal storage
|
1160
|
+
let values;
|
1161
|
+
if (Array.isArray(input)) {
|
1162
|
+
values = input;
|
1163
|
+
} else if (typeof input === 'string') {
|
1164
|
+
values = input === '' ? [] : [input];
|
1165
|
+
} else {
|
1166
|
+
values = [];
|
1167
|
+
}
|
1168
|
+
|
1154
1169
|
const oldValues = this._internals.value;
|
1155
1170
|
this._internals.value = values;
|
1156
1171
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class Chop::Form::TagField < Chop::Form::Field
|
2
|
+
def self.css_selector
|
3
|
+
"input-tag"
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?
|
7
|
+
field.tag_name == "input-tag"
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_value
|
11
|
+
field.all("tag-option").map(&:text)
|
12
|
+
end
|
13
|
+
|
14
|
+
def diff_value
|
15
|
+
get_value.join(", ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_value
|
19
|
+
if field[:multiple]
|
20
|
+
value.to_s.split(", ").map(&:strip)
|
21
|
+
else
|
22
|
+
value.to_s.strip
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def fill_in!
|
27
|
+
session.execute_script("document.getElementById('#{field[:id]}').value = #{set_value.to_json}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
When "I fill in the {string} tag field with {string}" do |field, value|
|
32
|
+
find_input_tag_field(field).click
|
33
|
+
page.driver.browser.keyboard.type(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
When "I remove {string} from the {string} tag field" do |value, field|
|
37
|
+
within find_input_tag_field(field) do
|
38
|
+
within find("tag-option", text: value).shadow_root do
|
39
|
+
find("button").trigger("click")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Then "I should see the following {string} tag field:" do |field, table|
|
45
|
+
tags = input_tag_value(find_input_tag_field(field))
|
46
|
+
table.diff! [tags]
|
47
|
+
end
|
48
|
+
|
49
|
+
Then "I should see an empty {string} tag field" do |field|
|
50
|
+
expect(find_input_tag_field(field)).to have_no_css("tag-option")
|
51
|
+
end
|
52
|
+
|
53
|
+
Then "I should see the following {string} available tag options:" do |field, table|
|
54
|
+
field = find_input_tag_field(field)
|
55
|
+
options = field.all("datalist option", visible: false).map { |e| e[:innerText] }
|
56
|
+
expect(options).to eq(table.raw.flatten)
|
57
|
+
end
|
58
|
+
|
59
|
+
Then "I should see the following {string} tag field autocomplete options:" do |field, table|
|
60
|
+
within find_input_tag_field(field).shadow_root do
|
61
|
+
expect(all("li").map(&:text)).to eq(table.raw.flatten)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_input_tag_field(label)
|
66
|
+
find("##{find("label", text: label)[:for]}")
|
67
|
+
end
|
68
|
+
|
69
|
+
def input_tag_value(field)
|
70
|
+
field.all("tag-option").map(&:text)
|
71
|
+
end
|
72
|
+
|
73
|
+
def input_tag_field actual, root, label: "Labels"
|
74
|
+
index = actual.index { |row| row.first == "Description" }
|
75
|
+
tags = input_tag_value(find_input_tag_field(label))
|
76
|
+
actual.insert index, [label, tags.join(", ")]
|
77
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard-tag_field
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- gemfiles/rails_7.2.gemfile
|
93
93
|
- gemfiles/rails_8.0.gemfile
|
94
94
|
- lib/bard/tag_field.rb
|
95
|
+
- lib/bard/tag_field/cucumber.rb
|
95
96
|
- lib/bard/tag_field/field.rb
|
96
97
|
- lib/bard/tag_field/form_builder.rb
|
97
98
|
- lib/bard/tag_field/version.rb
|