proscenium 0.19.0.beta10-x86_64-darwin → 0.19.0.beta12-x86_64-darwin
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 +0 -44
- data/lib/proscenium/bundled_gems.rb +1 -1
- data/lib/proscenium/css_module.rb +0 -5
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/middleware.rb +0 -6
- data/lib/proscenium/monkey.rb +2 -9
- data/lib/proscenium/phlex.rb +0 -6
- data/lib/proscenium/railtie.rb +0 -25
- data/lib/proscenium/react_componentable.rb +1 -1
- data/lib/proscenium/resolver.rb +0 -9
- data/lib/proscenium/version.rb +1 -1
- data/lib/proscenium.rb +6 -34
- metadata +24 -136
- data/lib/proscenium/registry/bundled_package.rb +0 -29
- data/lib/proscenium/registry/package.rb +0 -95
- data/lib/proscenium/registry/ruby_gem_package.rb +0 -30
- data/lib/proscenium/registry.rb +0 -29
- data/lib/proscenium/ruby_gems.rb +0 -67
- data/lib/proscenium/ui/breadcrumbs/component.module.css +0 -14
- data/lib/proscenium/ui/breadcrumbs/component.rb +0 -71
- data/lib/proscenium/ui/breadcrumbs/computed_element.rb +0 -69
- data/lib/proscenium/ui/breadcrumbs/control.rb +0 -95
- data/lib/proscenium/ui/breadcrumbs/mixins.css +0 -83
- data/lib/proscenium/ui/breadcrumbs.rb +0 -72
- data/lib/proscenium/ui/component.rb +0 -7
- data/lib/proscenium/ui/custom_element.js +0 -54
- data/lib/proscenium/ui/flash/bun.lock +0 -19
- data/lib/proscenium/ui/flash/index.css +0 -1
- data/lib/proscenium/ui/flash/index.js +0 -77
- data/lib/proscenium/ui/flash/node_modules/dom-mutations/index.d.ts +0 -33
- data/lib/proscenium/ui/flash/node_modules/dom-mutations/index.js +0 -44
- data/lib/proscenium/ui/flash/node_modules/dom-mutations/license +0 -9
- data/lib/proscenium/ui/flash/node_modules/dom-mutations/package.json +0 -59
- data/lib/proscenium/ui/flash/node_modules/dom-mutations/readme.md +0 -125
- data/lib/proscenium/ui/flash/node_modules/sourdough-toast/LICENSE +0 -20
- data/lib/proscenium/ui/flash/node_modules/sourdough-toast/README.md +0 -11
- data/lib/proscenium/ui/flash/node_modules/sourdough-toast/package.json +0 -44
- data/lib/proscenium/ui/flash/node_modules/sourdough-toast/src/sourdough-toast.css +0 -697
- data/lib/proscenium/ui/flash/node_modules/sourdough-toast/src/sourdough-toast.js +0 -537
- data/lib/proscenium/ui/flash/package.json +0 -11
- data/lib/proscenium/ui/flash.rb +0 -15
- data/lib/proscenium/ui/form/field_methods.rb +0 -88
- data/lib/proscenium/ui/form/fields/base.rb +0 -188
- data/lib/proscenium/ui/form/fields/checkbox/index.jsx +0 -48
- data/lib/proscenium/ui/form/fields/checkbox/index.module.css +0 -9
- data/lib/proscenium/ui/form/fields/checkbox/previews/basic.jsx +0 -8
- data/lib/proscenium/ui/form/fields/checkbox.rb +0 -32
- data/lib/proscenium/ui/form/fields/date.module.css +0 -27
- data/lib/proscenium/ui/form/fields/datetime.rb +0 -15
- data/lib/proscenium/ui/form/fields/hidden.rb +0 -9
- data/lib/proscenium/ui/form/fields/input/index.jsx +0 -71
- data/lib/proscenium/ui/form/fields/input/index.module.css +0 -13
- data/lib/proscenium/ui/form/fields/input/previews/basic.jsx +0 -8
- data/lib/proscenium/ui/form/fields/input.rb +0 -14
- data/lib/proscenium/ui/form/fields/radio_group.rb +0 -173
- data/lib/proscenium/ui/form/fields/radio_input/index.jsx +0 -44
- data/lib/proscenium/ui/form/fields/radio_input/index.module.css +0 -13
- data/lib/proscenium/ui/form/fields/radio_input/previews/basic.jsx +0 -8
- data/lib/proscenium/ui/form/fields/radio_input.rb +0 -17
- data/lib/proscenium/ui/form/fields/rich_textarea.css +0 -23
- data/lib/proscenium/ui/form/fields/rich_textarea.js +0 -6
- data/lib/proscenium/ui/form/fields/rich_textarea.rb +0 -18
- data/lib/proscenium/ui/form/fields/select.jsx +0 -47
- data/lib/proscenium/ui/form/fields/select.module.css +0 -46
- data/lib/proscenium/ui/form/fields/select.rb +0 -300
- data/lib/proscenium/ui/form/fields/tel.css +0 -297
- data/lib/proscenium/ui/form/fields/tel.js +0 -83
- data/lib/proscenium/ui/form/fields/tel.rb +0 -54
- data/lib/proscenium/ui/form/fields/textarea/index.jsx +0 -50
- data/lib/proscenium/ui/form/fields/textarea/index.module.css +0 -13
- data/lib/proscenium/ui/form/fields/textarea/previews/basic.jsx +0 -8
- data/lib/proscenium/ui/form/fields/textarea.rb +0 -18
- data/lib/proscenium/ui/form/translation.rb +0 -71
- data/lib/proscenium/ui/form.css +0 -52
- data/lib/proscenium/ui/form.rb +0 -211
- data/lib/proscenium/ui/props.css +0 -7
- data/lib/proscenium/ui/stimulus-loading.js +0 -65
- data/lib/proscenium/ui/test.js +0 -1
- data/lib/proscenium/ui/ujs/class.js +0 -15
- data/lib/proscenium/ui/ujs/data_confirm.js +0 -23
- data/lib/proscenium/ui/ujs/data_disable_with.js +0 -68
- data/lib/proscenium/ui/ujs/index.js +0 -9
- data/lib/proscenium/ui.rb +0 -11
- data/lib/proscenium/view_component/css_modules.rb +0 -11
- data/lib/proscenium/view_component/react_component.rb +0 -22
- data/lib/proscenium/view_component/sideload.rb +0 -4
- data/lib/proscenium/view_component.rb +0 -36
- /data/lib/proscenium/{ui/react-manager → react-manager}/index.jsx +0 -0
- /data/lib/proscenium/{ui/react-manager → react-manager}/react.js +0 -0
    
        data/lib/proscenium/ui/form.rb
    DELETED
    
    | @@ -1,211 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Proscenium::UI
         | 
| 4 | 
            -
              # Helpers to aid in building forms and associated inputs with built-in styling, and inspired by
         | 
| 5 | 
            -
              # Rails form helpers and SimpleForm.
         | 
| 6 | 
            -
              #
         | 
| 7 | 
            -
              # Start by creating the form with `Proscenium::UI::Form`, which expects a model
         | 
| 8 | 
            -
              # instance, and a block in which you define one or more fields. It automatically includes a hidden
         | 
| 9 | 
            -
              # authenticity token field for you.
         | 
| 10 | 
            -
              #
         | 
| 11 | 
            -
              # Example:
         | 
| 12 | 
            -
              #
         | 
| 13 | 
            -
              #   render Proscenium::UI::Form.new(User.new) do |f|
         | 
| 14 | 
            -
              #     f.text_field :name
         | 
| 15 | 
            -
              #     f.radio_group :role, %i[admin manager]
         | 
| 16 | 
            -
              #     f.submit 'Save'
         | 
| 17 | 
            -
              #   end
         | 
| 18 | 
            -
              #
         | 
| 19 | 
            -
              # The following fields (inputs) are available:
         | 
| 20 | 
            -
              #
         | 
| 21 | 
            -
              #   - `url_field` - <input> with 'url' type.
         | 
| 22 | 
            -
              #   - `text_field` - <input> with 'text' type.
         | 
| 23 | 
            -
              #   - `textarea_field` - <textarea>.
         | 
| 24 | 
            -
              #   - `rich_textarea_field` - A rich <textarea> using ActionText and Trix.
         | 
| 25 | 
            -
              #   - `email_field` - <input> with 'email' type.
         | 
| 26 | 
            -
              #   - `number_field` - <input> with 'number' type.
         | 
| 27 | 
            -
              #   - `color_field` - <input> with 'color' type.
         | 
| 28 | 
            -
              #   - `hidden_field` - <input> with 'hidden' type.
         | 
| 29 | 
            -
              #   - `search_field` - <input> with 'search' type.
         | 
| 30 | 
            -
              #   - `password_field` - <input> with 'password' type.
         | 
| 31 | 
            -
              #   - `tel_field` - <input> with 'tel' type.
         | 
| 32 | 
            -
              #   - `range_field` - <input> with 'range' type.
         | 
| 33 | 
            -
              #   - `time_field` - <input> with 'time' type.
         | 
| 34 | 
            -
              #   - `date_field` - <input> with 'date' type.
         | 
| 35 | 
            -
              #   - `week_field` - <input> with 'week' type.
         | 
| 36 | 
            -
              #   - `month_field` - <input> with 'month' type.
         | 
| 37 | 
            -
              #   - `datetime_local_field` - <input> with 'datetime-local' type.
         | 
| 38 | 
            -
              #   - `checkbox_field` - <input> with 'checkbox' type.
         | 
| 39 | 
            -
              #   - `radio_field` - <input> with 'radio' type.
         | 
| 40 | 
            -
              #   - `radio_group` - group of <input>'s with 'radio' type.
         | 
| 41 | 
            -
              #   - `select_field` - <select> input.
         | 
| 42 | 
            -
              #
         | 
| 43 | 
            -
              class Form < Proscenium::UI::Component
         | 
| 44 | 
            -
                extend ActiveSupport::Autoload
         | 
| 45 | 
            -
                extend Literal::Properties
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                autoload :FieldMethods
         | 
| 48 | 
            -
                autoload :Translation
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                module Fields
         | 
| 51 | 
            -
                  extend ActiveSupport::Autoload
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                  autoload :Base
         | 
| 54 | 
            -
                  autoload :Input
         | 
| 55 | 
            -
                  autoload :Hidden
         | 
| 56 | 
            -
                  autoload :RadioInput
         | 
| 57 | 
            -
                  autoload :Checkbox
         | 
| 58 | 
            -
                  autoload :Textarea
         | 
| 59 | 
            -
                  autoload :RichTextarea
         | 
| 60 | 
            -
                  autoload :RadioGroup
         | 
| 61 | 
            -
                  autoload :Select
         | 
| 62 | 
            -
                  autoload :Tel
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                include FieldMethods
         | 
| 66 | 
            -
                include Translation
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                STANDARD_METHOD_VERBS = %w[get post].freeze
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                def self.input_field(method_name, type:)
         | 
| 71 | 
            -
                  define_method method_name do |*args, **attributes|
         | 
| 72 | 
            -
                    merge_bang_attributes! args, attributes
         | 
| 73 | 
            -
                    render Fields::Input.new(args, @model, self, type:, **attributes)
         | 
| 74 | 
            -
                  end
         | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                prop :model, _Interface(:to_model), :positional, reader: :public
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                prop :method, _Union?(:get, :post, :put, :patch, :delete,
         | 
| 80 | 
            -
                                      'get', 'post', 'put', 'patch', 'delete') do |value|
         | 
| 81 | 
            -
                  value ||= 'patch' if @model.respond_to?(:persisted?) && @model.persisted?
         | 
| 82 | 
            -
                  value&.to_s&.downcase || 'post'
         | 
| 83 | 
            -
                end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                # The form action, which can be any value that can be passed to Rails `url_for` helper.
         | 
| 86 | 
            -
                prop :action, _Union?(String, Symbol, Array, Hash)
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                prop :attributes, Hash, :**
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                # Use the given `field_class` to render a custom field. This allows you to create a custom
         | 
| 91 | 
            -
                # form field on an as-needed basis. The `field_class` must be a subclass of
         | 
| 92 | 
            -
                # `Proscenium::UI::Form::Fields::Base`.
         | 
| 93 | 
            -
                #
         | 
| 94 | 
            -
                # Example:
         | 
| 95 | 
            -
                #
         | 
| 96 | 
            -
                #   render Proscenium::UI::Form.new @resource do |f|
         | 
| 97 | 
            -
                #     f.use_field Administrator::EmailField, :email, :required!
         | 
| 98 | 
            -
                #   end
         | 
| 99 | 
            -
                #
         | 
| 100 | 
            -
                # @param field_class [Class<Proscenium::UI::Form::Fields::Base>]
         | 
| 101 | 
            -
                # @param args [Array<Symbol>] name or nested names of model attribute
         | 
| 102 | 
            -
                # @param attributes [Hash] passed through to each input
         | 
| 103 | 
            -
                def use_field(field_class, *args, **attributes)
         | 
| 104 | 
            -
                  merge_bang_attributes! args, attributes
         | 
| 105 | 
            -
                  render field_class.new(args, model, self, **attributes)
         | 
| 106 | 
            -
                end
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                # Returns a button with type of 'submit', using the `value` given.
         | 
| 109 | 
            -
                #
         | 
| 110 | 
            -
                # @param value [String] Value of the `value` attribute.
         | 
| 111 | 
            -
                def submit(value = 'Save', **)
         | 
| 112 | 
            -
                  input(name: 'commit', type: :submit, value:, **)
         | 
| 113 | 
            -
                end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                # Returns a <div> with the given `message` as its content. If `message` is not given, and
         | 
| 116 | 
            -
                # `attribute` is, then first error message for the given model `attribute`.
         | 
| 117 | 
            -
                #
         | 
| 118 | 
            -
                # @param message [String] error message to display.
         | 
| 119 | 
            -
                # @param attribute [Symbol] name of the model attribute.
         | 
| 120 | 
            -
                def error(message: nil, attribute: nil, &content)
         | 
| 121 | 
            -
                  if message.nil? && attribute.nil? && !content
         | 
| 122 | 
            -
                    raise ArgumentError, 'One of `message:`, `attribute:` or a block is required'
         | 
| 123 | 
            -
                  end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                  if content
         | 
| 126 | 
            -
                    div class: :@error, &content
         | 
| 127 | 
            -
                  else
         | 
| 128 | 
            -
                    div class: :@error do
         | 
| 129 | 
            -
                      message || @model.errors[attribute]&.first
         | 
| 130 | 
            -
                    end
         | 
| 131 | 
            -
                  end
         | 
| 132 | 
            -
                end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
                def view_template(&block)
         | 
| 135 | 
            -
                  form action:, method:, **@attributes do
         | 
| 136 | 
            -
                    method_field
         | 
| 137 | 
            -
                    authenticity_token_field
         | 
| 138 | 
            -
                    error_for_base
         | 
| 139 | 
            -
                    yield_content(&block)
         | 
| 140 | 
            -
                  end
         | 
| 141 | 
            -
                end
         | 
| 142 | 
            -
             | 
| 143 | 
            -
                def error_for_base
         | 
| 144 | 
            -
                  return unless @model.errors.key?(:base)
         | 
| 145 | 
            -
             | 
| 146 | 
            -
                  callout :danger do |x|
         | 
| 147 | 
            -
                    x.title { 'Unable to save...' }
         | 
| 148 | 
            -
                    div { @model.errors.full_messages_for(:base).first }
         | 
| 149 | 
            -
                  end
         | 
| 150 | 
            -
                end
         | 
| 151 | 
            -
             | 
| 152 | 
            -
                def field_name(*names, multiple: false)
         | 
| 153 | 
            -
                  # Delete the `?` suffix if present.
         | 
| 154 | 
            -
                  lname = names.pop.to_s
         | 
| 155 | 
            -
                  names.append lname.delete_suffix('?').to_sym
         | 
| 156 | 
            -
             | 
| 157 | 
            -
                  @_view_context.field_name(ActiveModel::Naming.param_key(@model.class), *names,
         | 
| 158 | 
            -
                                            multiple:)
         | 
| 159 | 
            -
                end
         | 
| 160 | 
            -
             | 
| 161 | 
            -
                def field_id(*)
         | 
| 162 | 
            -
                  @_view_context.field_id(ActiveModel::Naming.param_key(@model.class), *)
         | 
| 163 | 
            -
                end
         | 
| 164 | 
            -
             | 
| 165 | 
            -
                def authenticity_token_field
         | 
| 166 | 
            -
                  return if method == 'get'
         | 
| 167 | 
            -
             | 
| 168 | 
            -
                  input(
         | 
| 169 | 
            -
                    name: 'authenticity_token',
         | 
| 170 | 
            -
                    type: 'hidden',
         | 
| 171 | 
            -
                    value: @_view_context.form_authenticity_token(form_options: { action:,
         | 
| 172 | 
            -
                                                                                  method: @method })
         | 
| 173 | 
            -
                  )
         | 
| 174 | 
            -
                end
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                def action
         | 
| 177 | 
            -
                  @_view_context.url_for(@action || @model)
         | 
| 178 | 
            -
                end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
                def method_field
         | 
| 181 | 
            -
                  return if STANDARD_METHOD_VERBS.include?(@method)
         | 
| 182 | 
            -
             | 
| 183 | 
            -
                  input type: 'hidden', name: '_method', value: @method, autocomplete: 'off'
         | 
| 184 | 
            -
                end
         | 
| 185 | 
            -
             | 
| 186 | 
            -
                def method
         | 
| 187 | 
            -
                  STANDARD_METHOD_VERBS.include?(@method) ? @method : 'post'
         | 
| 188 | 
            -
                end
         | 
| 189 | 
            -
             | 
| 190 | 
            -
                input_field :file_field, type: 'file'
         | 
| 191 | 
            -
                input_field :url_field, type: 'url'
         | 
| 192 | 
            -
                input_field :text_field, type: 'text'
         | 
| 193 | 
            -
                input_field :time_field, type: 'time'
         | 
| 194 | 
            -
                input_field :date_field, type: 'date'
         | 
| 195 | 
            -
                input_field :number_field, type: 'number'
         | 
| 196 | 
            -
                input_field :week_field, type: 'week'
         | 
| 197 | 
            -
                input_field :month_field, type: 'month'
         | 
| 198 | 
            -
                input_field :email_field, type: 'email'
         | 
| 199 | 
            -
                input_field :color_field, type: 'color'
         | 
| 200 | 
            -
                input_field :search_field, type: 'search'
         | 
| 201 | 
            -
                input_field :password_field, type: 'password'
         | 
| 202 | 
            -
                input_field :range_field, type: 'range'
         | 
| 203 | 
            -
             | 
| 204 | 
            -
                private
         | 
| 205 | 
            -
             | 
| 206 | 
            -
                def merge_bang_attributes!(attrs, kw_attributes, additional_bang_attrs: [])
         | 
| 207 | 
            -
                  Proscenium::Utils.merge_bang_attributes! attrs, kw_attributes,
         | 
| 208 | 
            -
                                                           %i[required disabled].concat(additional_bang_attrs)
         | 
| 209 | 
            -
                end
         | 
| 210 | 
            -
              end
         | 
| 211 | 
            -
            end
         | 
    
        data/lib/proscenium/ui/props.css
    DELETED
    
    
| @@ -1,65 +0,0 @@ | |
| 1 | 
            -
            export function lazyLoadControllersFrom(under, app, element = document) {
         | 
| 2 | 
            -
              const { controllerAttribute } = app.schema;
         | 
| 3 | 
            -
             | 
| 4 | 
            -
              lazyLoadExistingControllers(element);
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              // Lazy load new controllers.
         | 
| 7 | 
            -
              new MutationObserver((mutationsList) => {
         | 
| 8 | 
            -
                for (const { attributeName, target, type } of mutationsList) {
         | 
| 9 | 
            -
                  switch (type) {
         | 
| 10 | 
            -
                    case "attributes": {
         | 
| 11 | 
            -
                      if (
         | 
| 12 | 
            -
                        attributeName == controllerAttribute &&
         | 
| 13 | 
            -
                        target.getAttribute(controllerAttribute)
         | 
| 14 | 
            -
                      ) {
         | 
| 15 | 
            -
                        extractControllerNamesFrom(target).forEach((controllerName) =>
         | 
| 16 | 
            -
                          loadController(controllerName)
         | 
| 17 | 
            -
                        );
         | 
| 18 | 
            -
                      }
         | 
| 19 | 
            -
                    }
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                    case "childList": {
         | 
| 22 | 
            -
                      lazyLoadExistingControllers(target);
         | 
| 23 | 
            -
                    }
         | 
| 24 | 
            -
                  }
         | 
| 25 | 
            -
                }
         | 
| 26 | 
            -
              }).observe(element, {
         | 
| 27 | 
            -
                attributeFilter: [controllerAttribute],
         | 
| 28 | 
            -
                subtree: true,
         | 
| 29 | 
            -
                childList: true,
         | 
| 30 | 
            -
              });
         | 
| 31 | 
            -
             | 
| 32 | 
            -
              function lazyLoadExistingControllers(element) {
         | 
| 33 | 
            -
                Array.from(element.querySelectorAll(`[${controllerAttribute}]`))
         | 
| 34 | 
            -
                  .map(extractControllerNamesFrom)
         | 
| 35 | 
            -
                  .flat()
         | 
| 36 | 
            -
                  .forEach(loadController);
         | 
| 37 | 
            -
              }
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              function extractControllerNamesFrom(element) {
         | 
| 40 | 
            -
                return element
         | 
| 41 | 
            -
                  .getAttribute(controllerAttribute)
         | 
| 42 | 
            -
                  .split(/\s+/)
         | 
| 43 | 
            -
                  .filter((content) => content.length);
         | 
| 44 | 
            -
              }
         | 
| 45 | 
            -
             | 
| 46 | 
            -
              function loadController(name) {
         | 
| 47 | 
            -
                if (canRegisterController(name)) {
         | 
| 48 | 
            -
                  const fileToImport = `${under}/${name
         | 
| 49 | 
            -
                    .replace(/--/g, "/")
         | 
| 50 | 
            -
                    .replace(/-/g, "_")}_controller.js`;
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                  import(fileToImport)
         | 
| 53 | 
            -
                    .then((module) => {
         | 
| 54 | 
            -
                      canRegisterController(name) && app.register(name, module.default);
         | 
| 55 | 
            -
                    })
         | 
| 56 | 
            -
                    .catch((error) =>
         | 
| 57 | 
            -
                      console.error(`Failed to autoload controller: ${name}`, error)
         | 
| 58 | 
            -
                    );
         | 
| 59 | 
            -
                }
         | 
| 60 | 
            -
              }
         | 
| 61 | 
            -
             | 
| 62 | 
            -
              function canRegisterController(name) {
         | 
| 63 | 
            -
                return !app.router.modulesByIdentifier.has(name);
         | 
| 64 | 
            -
              }
         | 
| 65 | 
            -
            }
         | 
    
        data/lib/proscenium/ui/test.js
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            console.log("proscenium/test.js");
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            import DataConfirm from "./data_confirm";
         | 
| 2 | 
            -
            import DataDisableWith from "./data_disable_with";
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            export default class UJS {
         | 
| 5 | 
            -
              constructor() {
         | 
| 6 | 
            -
                this.dc = new DataConfirm();
         | 
| 7 | 
            -
                this.ddw = new DataDisableWith();
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                document.addEventListener("submit", this, { capture: true });
         | 
| 10 | 
            -
              }
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              handleEvent(event) {
         | 
| 13 | 
            -
                this.dc.onSubmit(event) && this.ddw.onSubmit(event);
         | 
| 14 | 
            -
              }
         | 
| 15 | 
            -
            }
         | 
| @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            export default class DataConfirm {
         | 
| 2 | 
            -
              onSubmit = (event) => {
         | 
| 3 | 
            -
                if (
         | 
| 4 | 
            -
                  !event.target.matches("[data-turbo=true]") &&
         | 
| 5 | 
            -
                  event.submitter &&
         | 
| 6 | 
            -
                  "confirm" in event.submitter.dataset
         | 
| 7 | 
            -
                ) {
         | 
| 8 | 
            -
                  const v = event.submitter.dataset.confirm;
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  if (
         | 
| 11 | 
            -
                    v !== "false" &&
         | 
| 12 | 
            -
                    !confirm(v === "true" || v === "" ? "Are you sure?" : v)
         | 
| 13 | 
            -
                  ) {
         | 
| 14 | 
            -
                    event.preventDefault();
         | 
| 15 | 
            -
                    event.stopPropagation();
         | 
| 16 | 
            -
                    event.stopImmediatePropagation();
         | 
| 17 | 
            -
                    return false;
         | 
| 18 | 
            -
                  }
         | 
| 19 | 
            -
                }
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                return true;
         | 
| 22 | 
            -
              };
         | 
| 23 | 
            -
            }
         | 
| @@ -1,68 +0,0 @@ | |
| 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 | 
            -
            }
         | 
| @@ -1,9 +0,0 @@ | |
| 1 | 
            -
            export default async () => {
         | 
| 2 | 
            -
              window.Proscenium = window.Proscenium || {};
         | 
| 3 | 
            -
             | 
| 4 | 
            -
              if (!window.Proscenium.UJS) {
         | 
| 5 | 
            -
                const classPath = "/node_modules/@rubygems/proscenium/ujs/class.js";
         | 
| 6 | 
            -
                const module = await import(classPath);
         | 
| 7 | 
            -
                window.Proscenium.UJS = new module.default();
         | 
| 8 | 
            -
              }
         | 
| 9 | 
            -
            };
         | 
    
        data/lib/proscenium/ui.rb
    DELETED
    
    
| @@ -1,22 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Proscenium
         | 
| 4 | 
            -
              # Renders a <div> for use with React components, with data attributes specifying the component
         | 
| 5 | 
            -
              # path and props.
         | 
| 6 | 
            -
              #
         | 
| 7 | 
            -
              # If a content block is given, that content will be rendered inside the component, allowing for a
         | 
| 8 | 
            -
              # "loading" UI. If no block is given, then a "loading..." text will be rendered. It is intended
         | 
| 9 | 
            -
              # that the component is mounted to this div, and the loading UI will then be replaced with the
         | 
| 10 | 
            -
              # component's rendered output.
         | 
| 11 | 
            -
              class ViewComponent::ReactComponent < ViewComponent
         | 
| 12 | 
            -
                self.abstract_class = true
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                include ReactComponentable
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                def call
         | 
| 17 | 
            -
                  tag.send root_tag, data: data_attributes do
         | 
| 18 | 
            -
                    tag.div content || 'loading...'
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
            end
         | 
| @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            class Proscenium::ViewComponent < ViewComponent::Base
         | 
| 4 | 
            -
              extend ActiveSupport::Autoload
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              autoload :Sideload
         | 
| 7 | 
            -
              autoload :ReactComponent
         | 
| 8 | 
            -
              autoload :CssModules
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              include Proscenium::SourcePath
         | 
| 11 | 
            -
              include CssModules
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              module Sideload
         | 
| 14 | 
            -
                def before_render
         | 
| 15 | 
            -
                  Proscenium::SideLoad.sideload_inheritance_chain self, controller.sideload_assets_options
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  super
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
              class_attribute :sideload_assets_options
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              class << self
         | 
| 24 | 
            -
                attr_accessor :abstract_class
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                def inherited(child)
         | 
| 27 | 
            -
                  child.prepend Sideload
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                  super
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                def sideload_assets(value)
         | 
| 33 | 
            -
                  self.sideload_assets_options = value
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         |