phlexy_ui 0.1.18 → 0.1.20
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/lib/phlexy_ui/attribute_set.rb +47 -12
- data/lib/phlexy_ui/base.rb +2 -2
- data/lib/phlexy_ui/checkbox.rb +8 -2
- data/lib/phlexy_ui/collapsible_sub_menu.rb +1 -1
- data/lib/phlexy_ui/tab_with_content.rb +2 -1
- data/lib/phlexy_ui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e92e0e137db4f235a6271b85a4916c64d725a6201af324e31aae6774e52cfdc9
|
4
|
+
data.tar.gz: 4005ccdeece88c2ac24bbefff65fc36a3e9d14473028e04c9cadd6a55aa343e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf059089b3566b9647f41b6fde7c227f34ae08d3b1d852afe9781c058ef9f2f684219871f450f9bf27592f0c2909cd9b274e7355d4332d65937b3f863966e8f
|
7
|
+
data.tar.gz: c69976c4a84ce88633bbcd8943f706af196fb5f45407bb5194dccd4830fd28de0e46bedba19b794171df89f11707e3765b20aa27ecc8652fbfdd07be5ad5ef60
|
@@ -1,28 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PhlexyUI
|
4
|
+
# @private
|
5
|
+
#
|
6
|
+
# Converts component modifiers and options into HTML attributes.
|
7
|
+
# This is an internal class used by Base components.
|
8
|
+
#
|
9
|
+
# Internal Usage:
|
10
|
+
# # Component defines an attributes map
|
11
|
+
# ATTRIBUTES_MAP = { open: { checked: true }, closed: true }
|
12
|
+
#
|
13
|
+
# # Attributes can come from modifiers or options:
|
14
|
+
# # tab(:open) #=> { checked: true }
|
15
|
+
# # tab(open: true) #=> { checked: true }
|
16
|
+
# # tab(open: false) #=> {}
|
17
|
+
# # tab(:closed) #=> { closed: true }
|
18
|
+
# # tab(closed: true) #=> { closed: true }
|
19
|
+
# # tab(closed: false) #=> {}
|
2
20
|
class AttributeSet
|
3
|
-
def initialize(base_modifiers, attributes_map)
|
21
|
+
def initialize(base_modifiers, options, attributes_map)
|
4
22
|
@base_modifiers = base_modifiers
|
23
|
+
@options = options
|
5
24
|
@attributes_map = attributes_map
|
6
25
|
end
|
7
26
|
|
8
27
|
def to_h
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
28
|
+
result = {}
|
29
|
+
|
30
|
+
# Process modifiers first
|
31
|
+
base_modifiers.each do |modifier|
|
32
|
+
next unless attributes_map.key?(modifier)
|
33
|
+
next if options.key?(modifier)
|
34
|
+
|
35
|
+
process_attribute(modifier, true, result)
|
17
36
|
end
|
37
|
+
|
38
|
+
# Then process options (overriding modifiers)
|
39
|
+
options.each do |key, value|
|
40
|
+
next unless attributes_map.key?(key)
|
41
|
+
next unless value
|
42
|
+
|
43
|
+
process_attribute(key, value, result)
|
44
|
+
end
|
45
|
+
|
46
|
+
result
|
18
47
|
end
|
19
48
|
|
20
49
|
private
|
21
50
|
|
22
|
-
attr_reader :base_modifiers, :attributes_map
|
51
|
+
attr_reader :base_modifiers, :options, :attributes_map
|
23
52
|
|
24
|
-
def
|
25
|
-
|
53
|
+
def process_attribute(key, value, result)
|
54
|
+
mapped_value = attributes_map[key]
|
55
|
+
|
56
|
+
if mapped_value.is_a?(Hash)
|
57
|
+
result.merge!(mapped_value)
|
58
|
+
else
|
59
|
+
result[key] = mapped_value
|
60
|
+
end
|
26
61
|
end
|
27
62
|
end
|
28
63
|
end
|
data/lib/phlexy_ui/base.rb
CHANGED
@@ -48,8 +48,8 @@ module PhlexyUI
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def generate_attributes(base_modifiers, attributes_map)
|
52
|
-
AttributeSet.new(base_modifiers, attributes_map).to_h
|
51
|
+
def generate_attributes(base_modifiers, options, attributes_map)
|
52
|
+
AttributeSet.new(base_modifiers, options, attributes_map).to_h
|
53
53
|
end
|
54
54
|
|
55
55
|
def render_as(*, as:, **, &)
|
data/lib/phlexy_ui/checkbox.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module PhlexyUI
|
4
4
|
class Checkbox < Base
|
5
5
|
def view_template(&)
|
6
|
-
attributes = generate_attributes(base_modifiers, ATTRIBUTES_MAP)
|
6
|
+
attributes = generate_attributes(base_modifiers, options, ATTRIBUTES_MAP)
|
7
7
|
|
8
8
|
generate_classes!(
|
9
9
|
component_html_class: :checkbox,
|
@@ -11,7 +11,13 @@ module PhlexyUI
|
|
11
11
|
base_modifiers:,
|
12
12
|
options:
|
13
13
|
).then do |classes|
|
14
|
-
input(
|
14
|
+
input(
|
15
|
+
type: :checkbox,
|
16
|
+
class: classes,
|
17
|
+
**options.except(*ATTRIBUTES_MAP.keys),
|
18
|
+
**attributes,
|
19
|
+
&
|
20
|
+
)
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
@@ -15,6 +15,7 @@ module PhlexyUI
|
|
15
15
|
|
16
16
|
attributes = generate_attributes(
|
17
17
|
base_modifiers,
|
18
|
+
options,
|
18
19
|
ATTRIBUTES_MAP
|
19
20
|
)
|
20
21
|
|
@@ -31,7 +32,7 @@ module PhlexyUI
|
|
31
32
|
role: :tab,
|
32
33
|
aria_label: title,
|
33
34
|
**attributes,
|
34
|
-
**options
|
35
|
+
**options.except(*ATTRIBUTES_MAP.keys)
|
35
36
|
)
|
36
37
|
end
|
37
38
|
|
data/lib/phlexy_ui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlexy_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Alejandro Aguilar Ramos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|