stimulus-overlay-helpers 3.2.0 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27ec466499aee219c29aa0470de426e13cdd42ae8e85d384b6941edae1b4e334
4
- data.tar.gz: c1bb2bb9af42d7713b5bfd80e965b5826b50d8a01732125e76a67eb18623ff14
3
+ metadata.gz: 0a14bf1da5509f2edad3a45fb319b77ddf7f4f1e4a2736798d79adda530cbfc3
4
+ data.tar.gz: e051e735af777ccd80178649e739983bc832a61de1f30944b5e7ae4bca778751
5
5
  SHA512:
6
- metadata.gz: aa15787822e03e812aa12e1706a6867694c7de80cf007454162dad072e1351de351e30e17cebef500837324ee4f50504b5abe03ee0b29ba74023b5aed59290fe
7
- data.tar.gz: '0494b1cc71e3bb4bf0ceeeb2652743809b5457048886b5b8376e207252d5d980e13ff38f30f20b8d7ca74af3d80366dec777664be74d2ed4d70be6fd38054839'
6
+ metadata.gz: 77b56074cdc73407d50c7eef236b3dc21f47b52efb6ffbc0f8edf5c19faa8d44ed6d636ad794cf5ba514f059de9db1356f82941c31eba3a15338f7ac88c4a88a
7
+ data.tar.gz: 59577a438d0f99ef4186eae5865f40cda7c4c53e5ba912dba4f4251f76a76ab24ad7c7d25c3e9f47f8165998a9bd62acda7d603e9af5b4c041e6ed0c7bbec9a1
data/README.md CHANGED
@@ -63,4 +63,14 @@ This matches the behavior of the [Svelte overlays from `@csedl/hotwire-svelte-he
63
63
  tooltip-content
64
64
  ```
65
65
 
66
+ ## Create Dropdown-Panel on opening
67
+
68
+ When `src` attribute is passed and, on opening, no panel is rendered, which is the case when:
69
+
70
+ - the button is rendered within a turbo-frame and therefore no content_for is working
71
+
72
+ Then, on opening, the panel is created by the `@csedl/hotwire-svelte-helpers` package
73
+
74
+ ## License
75
+
66
76
  License: MIT
@@ -1,7 +1,6 @@
1
1
  module StimulusOverlayHelpers
2
2
  module ViewHelpers
3
3
 
4
-
5
4
  #== dropdown helper
6
5
  # @param [button_content] Proc or String for content of the button element
7
6
  # @param [panel_at_place] true (default: false) => it would render the panel into content_for(:overlays_box) on sticky parts (left-menu / top-bar) panels should be at place for avoiding that the panel would scroll with the content
@@ -23,7 +22,8 @@ module StimulusOverlayHelpers
23
22
  panel_at_place = options.delete(:panel_at_place)
24
23
  src = options.delete(:src)
25
24
  button_class = [options.delete(:button_class), 'dropdown-button', options[:class]].compact.join(' ')
26
- panel_class = [options.delete(:class), 'dropdown-panel'].compact.join(' ')
25
+ panel_class = [options.delete(:panel_class), 'dropdown-panel'].compact.join(' ')
26
+
27
27
  close_btn_proc = StimulusOverlayHelpers.close_button_proc
28
28
 
29
29
  id = "dropdown-panel-#{SecureRandom.hex(4)}"
@@ -34,6 +34,11 @@ module StimulusOverlayHelpers
34
34
 
35
35
  button_content = capture(&panel_content_button = button_content) if button_content.is_a?(Proc)
36
36
  button_options = options.merge(class: button_class, data: { controller: 'hotwire-svelte-helpers-dropdown', panel_id: id })
37
+ if src.present?
38
+ button_options['data-src'] = src
39
+ button_options["data-overlay-class"] = panel_class
40
+ button_options["data-overlay-title"] = title
41
+ end
37
42
  button_element = content_tag(:div, button_content, button_options)
38
43
 
39
44
  # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -63,7 +68,7 @@ module StimulusOverlayHelpers
63
68
  if panel_at_place
64
69
  button_element + panel_element
65
70
  else
66
- content_for(:overlays_box, panel_element)
71
+ content_for(:overlays_box, panel_element) unless src.present? && !block_given?
67
72
  button_element
68
73
  end
69
74
  end
@@ -85,7 +90,7 @@ module StimulusOverlayHelpers
85
90
  panel_at_place = options.delete(:panel_at_place)
86
91
  src = options.delete(:src)
87
92
  button_class = [options.delete(:button_class) || 'modal-button', options[:class]].compact.join(' ')
88
- panel_class = [options.delete(:class), 'modal-panel'].compact.join(' ')
93
+ panel_class = [options.delete(:modal_class), 'modal-panel'].compact.join(' ')
89
94
  close_btn_proc = StimulusOverlayHelpers.close_button_proc
90
95
 
91
96
  id = "modal-overlay-#{SecureRandom.hex(4)}"
@@ -96,6 +101,10 @@ module StimulusOverlayHelpers
96
101
 
97
102
  button_content = capture(&button_content) if button_content.is_a?(Proc)
98
103
  button_options = options.merge(class: button_class, data: { controller: 'hotwire-svelte-helpers-modal', panel_id: id })
104
+ if src.present?
105
+ button_options['data-src'] = src
106
+ button_options["data-overlay-class"] = panel_class
107
+ end
99
108
  button_element = content_tag(:div, button_content, button_options)
100
109
 
101
110
  # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -126,7 +135,7 @@ module StimulusOverlayHelpers
126
135
  if panel_at_place
127
136
  button_element + overlay_element
128
137
  else
129
- content_for(:overlays_box, overlay_element)
138
+ content_for(:overlays_box, overlay_element) unless src.present? && !block_given?
130
139
  button_element
131
140
  end
132
141
  end
@@ -169,7 +178,7 @@ module StimulusOverlayHelpers
169
178
  panel_options['data-src'] = src if src.present?
170
179
 
171
180
  panel_element = content_tag(:div, panel_options) do
172
- content_tag( :div, '', id: "arrow") +
181
+ content_tag(:div, '', id: "arrow") +
173
182
  content_tag(:div, tip, class: 'tooltip-content')
174
183
  end
175
184
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus-overlay-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair