proscenium 0.15.0.beta.3-aarch64-linux → 0.15.0.beta.4-aarch64-linux
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/proscenium/css_module/rewriter.rb +21 -5
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/libs/ujs/class.js +17 -0
- data/lib/proscenium/libs/ujs/data_confirm.js +16 -0
- data/lib/proscenium/libs/ujs/data_disable_with.js +68 -0
- data/lib/proscenium/libs/ujs/index.js +9 -0
- data/lib/proscenium/version.rb +1 -1
- metadata +6 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 98ba1cf47000b7710c392df93abea47f68cbf699920d33e6b34301404e3e122c
         | 
| 4 | 
            +
              data.tar.gz: fd4595195e4e3942b3b045a826da4212e06beb9615bbacd5033ed10bf16267ec
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0c88d5450c899cc1b8d6819220bdbeed9e045d0e3d795059078bd74a45f05eb4e03478a8e5188e7b92e2bd432ece02141c982d872951074b4b56a51349b01852
         | 
| 7 | 
            +
              data.tar.gz: b4d45b249de0e08a678c34fc801eaa20cf3cf961da5cda077145516cb78deea4ad9d2fc326a9267636e97a7c9b54150b269610dc68096b65296c049ac169f95b
         | 
| @@ -8,12 +8,28 @@ module Proscenium | |
| 8 8 | 
             
                class Rewriter < RubyNext::Language::Rewriters::Text
         | 
| 9 9 | 
             
                  NAME = 'proscenium-css-module'
         | 
| 10 10 |  | 
| 11 | 
            -
                  def  | 
| 12 | 
            -
                    source.gsub( | 
| 13 | 
            -
                       | 
| 11 | 
            +
                  def rewrite(source)
         | 
| 12 | 
            +
                    source = source.gsub(/%i\[((@[\w@ ]+)|([\w@ ]+ @[\w@ ]+))\]/) do |_|
         | 
| 13 | 
            +
                      arr = ::Regexp.last_match(1).split.map do |x|
         | 
| 14 | 
            +
                        x.start_with?('@') ? css_module_string(x[1..]) : ":#{x}"
         | 
| 15 | 
            +
                      end
         | 
| 16 | 
            +
                      "[#{arr.join(',')}]"
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    source.gsub(/:@([\w]+)/) do |_|
         | 
| 20 | 
            +
                      context.track!(self)
         | 
| 21 | 
            +
                      css_module_string(::Regexp.last_match(1))
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  private
         | 
| 14 26 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 27 | 
            +
                  def css_module_string(name)
         | 
| 28 | 
            +
                    if (path = Pathname.new(context.path).sub_ext('.module.css')).exist?
         | 
| 29 | 
            +
                      tname = Transformer.new(path).class_name!(name, name.dup).first
         | 
| 30 | 
            +
                      "Proscenium::CssModule::Name.new(:@#{name}, '#{tname}')"
         | 
| 31 | 
            +
                    else
         | 
| 32 | 
            +
                      "Proscenium::CssModule::Name.new(:@#{name}, css_module(:#{name}))"
         | 
| 17 33 | 
             
                    end
         | 
| 18 34 | 
             
                  end
         | 
| 19 35 | 
             
                end
         | 
| Binary file | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            import DataConfirm from "./data_confirm";
         | 
| 2 | 
            +
            import DataDisableWith from "./data_disable_with";
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            export default class UJS {
         | 
| 5 | 
            +
              constructor() {
         | 
| 6 | 
            +
                const dc = new DataConfirm();
         | 
| 7 | 
            +
                const ddw = new DataDisableWith();
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                document.body.addEventListener(
         | 
| 10 | 
            +
                  "submit",
         | 
| 11 | 
            +
                  (event) => {
         | 
| 12 | 
            +
                    dc.onSubmit(event) && ddw.onSubmit(event);
         | 
| 13 | 
            +
                  },
         | 
| 14 | 
            +
                  { capture: true }
         | 
| 15 | 
            +
                );
         | 
| 16 | 
            +
              }
         | 
| 17 | 
            +
            }
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            export default class DataConfirm {
         | 
| 2 | 
            +
              onSubmit = event => {
         | 
| 3 | 
            +
                if (!event.target.matches('[data-turbo=true]') && 'confirm' in event.submitter.dataset) {
         | 
| 4 | 
            +
                  const v = event.submitter.dataset.confirm
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  if (v !== 'false' && !confirm(v === 'true' || v === '' ? 'Are you sure?' : v)) {
         | 
| 7 | 
            +
                    event.preventDefault()
         | 
| 8 | 
            +
                    event.stopPropagation()
         | 
| 9 | 
            +
                    event.stopImmediatePropagation()
         | 
| 10 | 
            +
                    return false
         | 
| 11 | 
            +
                  }
         | 
| 12 | 
            +
                }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                return true
         | 
| 15 | 
            +
              }
         | 
| 16 | 
            +
            }
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            export default class DataDisableWith {
         | 
| 2 | 
            +
              onSubmit = event => {
         | 
| 3 | 
            +
                const target = event.target
         | 
| 4 | 
            +
                const formId = target.id
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                if (target.matches('[data-turbo=true]')) return
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                const submitElements = Array.from(
         | 
| 9 | 
            +
                  target.querySelectorAll(
         | 
| 10 | 
            +
                    ['input[type=submit][data-disable-with]', 'button[type=submit][data-disable-with]'].join(
         | 
| 11 | 
            +
                      ', '
         | 
| 12 | 
            +
                    )
         | 
| 13 | 
            +
                  )
         | 
| 14 | 
            +
                )
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                submitElements.push(
         | 
| 17 | 
            +
                  ...Array.from(
         | 
| 18 | 
            +
                    document.querySelectorAll(
         | 
| 19 | 
            +
                      [
         | 
| 20 | 
            +
                        `input[type=submit][data-disable-with][form='${formId}']`,
         | 
| 21 | 
            +
                        `button[type=submit][data-disable-with][form='${formId}']`
         | 
| 22 | 
            +
                      ].join(', ')
         | 
| 23 | 
            +
                    )
         | 
| 24 | 
            +
                  )
         | 
| 25 | 
            +
                )
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                for (const ele of submitElements) {
         | 
| 28 | 
            +
                  if (ele.hasAttribute('form') && ele.getAttribute('form') !== target.id) continue
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  this.#disableButton(ele)
         | 
| 31 | 
            +
                }
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              #disableButton(ele) {
         | 
| 35 | 
            +
                const defaultTextValue = 'Please wait...'
         | 
| 36 | 
            +
                let textValue = ele.dataset.disableWith || defaultTextValue
         | 
| 37 | 
            +
                if (textValue === 'false') return
         | 
| 38 | 
            +
                if (textValue === 'true') {
         | 
| 39 | 
            +
                  textValue = defaultTextValue
         | 
| 40 | 
            +
                }
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                ele.disabled = true
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                if (ele.matches('button')) {
         | 
| 45 | 
            +
                  ele.dataset.valueBeforeDisabled = ele.innerHTML
         | 
| 46 | 
            +
                  ele.innerHTML = textValue
         | 
| 47 | 
            +
                } else {
         | 
| 48 | 
            +
                  ele.dataset.valueBeforeDisabled = ele.value
         | 
| 49 | 
            +
                  ele.value = textValue
         | 
| 50 | 
            +
                }
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                if (ele.resetDisableWith === undefined) {
         | 
| 53 | 
            +
                  // This function can be called on the element to reset the disabled state. Useful for when
         | 
| 54 | 
            +
                  // form submission fails, and the button should be re-enabled.
         | 
| 55 | 
            +
                  ele.resetDisableWith = function () {
         | 
| 56 | 
            +
                    this.disabled = false
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    if (this.matches('button')) {
         | 
| 59 | 
            +
                      this.innerHTML = this.dataset.valueBeforeDisabled
         | 
| 60 | 
            +
                    } else {
         | 
| 61 | 
            +
                      this.value = this.dataset.valueBeforeDisabled
         | 
| 62 | 
            +
                    }
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    delete this.dataset.valueBeforeDisabled
         | 
| 65 | 
            +
                  }
         | 
| 66 | 
            +
                }
         | 
| 67 | 
            +
              }
         | 
| 68 | 
            +
            }
         | 
    
        data/lib/proscenium/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: proscenium
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.15.0.beta. | 
| 4 | 
            +
              version: 0.15.0.beta.4
         | 
| 5 5 | 
             
            platform: aarch64-linux
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Joel Moss
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-03- | 
| 11 | 
            +
            date: 2024-03-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -118,6 +118,10 @@ files: | |
| 118 118 | 
             
            - lib/proscenium/libs/react-manager/react.js
         | 
| 119 119 | 
             
            - lib/proscenium/libs/stimulus-loading.js
         | 
| 120 120 | 
             
            - lib/proscenium/libs/test.js
         | 
| 121 | 
            +
            - lib/proscenium/libs/ujs/class.js
         | 
| 122 | 
            +
            - lib/proscenium/libs/ujs/data_confirm.js
         | 
| 123 | 
            +
            - lib/proscenium/libs/ujs/data_disable_with.js
         | 
| 124 | 
            +
            - lib/proscenium/libs/ujs/index.js
         | 
| 121 125 | 
             
            - lib/proscenium/log_subscriber.rb
         | 
| 122 126 | 
             
            - lib/proscenium/middleware.rb
         | 
| 123 127 | 
             
            - lib/proscenium/middleware/base.rb
         |