view_component_reflex 3.2.0 → 3.3.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/README.md +5 -2
- data/lib/view_component_reflex/reflex.rb +9 -4
- data/lib/view_component_reflex/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f83ad05fefd096a38658392650961db6eddc0bcd23597eb3b99dac0172461f8d
         | 
| 4 | 
            +
              data.tar.gz: dfa368d0bd5ff81f66c42b03f81ea084302c1d150e82fccef5e74006ecaf967c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1530f410f27aefa0ecf788dbac750f3772f86132e92a7cae5ca21846e0ded0e8e3cbf52b1c8aad3d3fbb8aee751da77998e6b67696be4dcc88cb96bd7dbbab48
         | 
| 7 | 
            +
              data.tar.gz: ef01d4cfd26a466f0b009aca9f16ca91866c9d82a0076015b239fcf32b5132054ea6a557484cba9677d17adf43137ceed42b95cad7f60f728a45badbb632c5d3
         | 
    
        data/README.md
    CHANGED
    
    | @@ -309,8 +309,11 @@ end | |
| 309 309 | 
             
            By default (since version `2.3.2`), view_component_reflex stores component state in session. You can optionally set the state adapter
         | 
| 310 310 | 
             
            to use the memory by changing `config.state_adapter` to `ViewComponentReflex::StateAdapter::Memory`.
         | 
| 311 311 |  | 
| 312 | 
            -
            Optionally, you can also store state right in the dom with `ViewComponentReflex::StateAdapter::Dom`. | 
| 313 | 
            -
            adapter requires the `data-reflex-dataset=" | 
| 312 | 
            +
            Optionally, you can also store state right in the dom with `ViewComponentReflex::StateAdapter::Dom`.
         | 
| 313 | 
            +
            Note that the DOM adapter requires the `data-reflex-dataset="children"` property to be set on anything firing the reflex. You can mix it with other options like `data-reflex-dataset="ancestors children"`.
         | 
| 314 | 
            +
            Optionally you can include all datasets in the reflex `data-reflex-dataset="*"` but in large applications you may want to limit the amount of data being transferred only to what is necessary.
         | 
| 315 | 
            +
             | 
| 316 | 
            +
            When using the `ViewComponentReflex::StateAdapter::Dom` make sure your key does not contain underscores and is limited to max. 80 characters. That's important when you'd be using customized [collection_key](#collections) which increases the length of the key.
         | 
| 314 317 |  | 
| 315 318 | 
             
            ## Custom State Adapters
         | 
| 316 319 |  | 
| @@ -11,6 +11,10 @@ module ViewComponentReflex | |
| 11 11 | 
             
                  Nokogiri::HTML(controller.response.body)
         | 
| 12 12 | 
             
                end
         | 
| 13 13 |  | 
| 14 | 
            +
                def cable_ready
         | 
| 15 | 
            +
                  CableReady::Channels.instance[stream]
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 14 18 | 
             
                def refresh!(primary_selector = nil, *rest)
         | 
| 15 19 | 
             
                  save_state
         | 
| 16 20 |  | 
| @@ -24,7 +28,7 @@ module ViewComponentReflex | |
| 24 28 | 
             
                    [primary_selector, *rest].each do |s|
         | 
| 25 29 | 
             
                      html = document.css(s)
         | 
| 26 30 | 
             
                      if html.present?
         | 
| 27 | 
            -
                         | 
| 31 | 
            +
                        cable_ready.morph(
         | 
| 28 32 | 
             
                          selector: s,
         | 
| 29 33 | 
             
                          html: html.inner_html,
         | 
| 30 34 | 
             
                          children_only: true,
         | 
| @@ -36,7 +40,7 @@ module ViewComponentReflex | |
| 36 40 | 
             
                  else
         | 
| 37 41 | 
             
                    refresh_component!
         | 
| 38 42 | 
             
                  end
         | 
| 39 | 
            -
                   | 
| 43 | 
            +
                  cable_ready.broadcast
         | 
| 40 44 | 
             
                end
         | 
| 41 45 |  | 
| 42 46 | 
             
                def stream
         | 
| @@ -60,7 +64,7 @@ module ViewComponentReflex | |
| 60 64 | 
             
                end
         | 
| 61 65 |  | 
| 62 66 | 
             
                def refresh_component!
         | 
| 63 | 
            -
                   | 
| 67 | 
            +
                  cable_ready.morph(
         | 
| 64 68 | 
             
                    selector: selector,
         | 
| 65 69 | 
             
                    children_only: true,
         | 
| 66 70 | 
             
                    html: component_document.css(selector).to_html,
         | 
| @@ -187,7 +191,8 @@ module ViewComponentReflex | |
| 187 191 | 
             
                    :prevent_refresh!,
         | 
| 188 192 | 
             
                    :selector,
         | 
| 189 193 | 
             
                    :stimulate,
         | 
| 190 | 
            -
                    :stream_to
         | 
| 194 | 
            +
                    :stream_to,
         | 
| 195 | 
            +
                    :cable_ready
         | 
| 191 196 | 
             
                  ]
         | 
| 192 197 | 
             
                  exposed_methods.each do |meth|
         | 
| 193 198 | 
             
                    @component.define_singleton_method(meth) do |*a|
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: view_component_reflex
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3. | 
| 4 | 
            +
              version: 3.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Joshua LeBlanc
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2023-01-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 116 116 | 
             
                - !ruby/object:Gem::Version
         | 
| 117 117 | 
             
                  version: '0'
         | 
| 118 118 | 
             
            requirements: []
         | 
| 119 | 
            -
            rubygems_version: 3.3. | 
| 119 | 
            +
            rubygems_version: 3.3.7
         | 
| 120 120 | 
             
            signing_key: 
         | 
| 121 121 | 
             
            specification_version: 4
         | 
| 122 122 | 
             
            summary: Allow stimulus reflexes in a view component
         |