glimmer-dsl-web 0.6.10 → 0.7.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: 19e269462e5ace48d73d5c76624b4d79f2a37f7679a410526f64aaceef4a0552
4
- data.tar.gz: 24ccdc20a32122070edd290fc8b41375aac19d730bc974dcf96f89a8104aef63
3
+ metadata.gz: 1ff3ef1efa40dc4dcc6e202544e7d0fa7be60c80d1f3dc9c465ed27cf62610df
4
+ data.tar.gz: da8851cd3e896f236c5cf45b23ff234ceb5854a6814a213e7311bc5f553910f8
5
5
  SHA512:
6
- metadata.gz: fb309b58ee1543098c7be8fd45dd66c067a21da9898f63dafbb4383ddc4827d42e9301b46cbe7c3e1deaf0fb10cc464538e71ee7b800c4eac78bffaf363b6448
7
- data.tar.gz: ea766a952146e62707ebf3cba8d8da6e646489b277c0ee5d58790c5e284099e71cbb4a8fc39d334c96a096a5c25c760c12e17e92a411910876260c8a82ac2f6f
6
+ metadata.gz: 145f156c520f3e25b0f4251fba654fcac9668edf5e03473aa4891fcf970ea92189d8a64be0f93f7fcbd81a9fc28ae541ccf6c99088ce64bbeb9eb9bb97c65450
7
+ data.tar.gz: 53ab737627d2cc6fac28e94f6e372a46f9a21af784afb5c4618509a874a684ff574eb85aa6a5a6c469b264c36257c5f66e8469f9d9825442e119341d9e1210ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.0
4
+
5
+ - Rename `element-ID` element CSS classes to `glimmer-element-ID` for a more unique class name that nobody else would be using
6
+ - Rename `element` element CSS class to `glimmer-root` while only setting on the root element in a Glimmer element hierarchy.
7
+
8
+ ## 0.6.12
9
+
10
+ - Fix issue with Glimmer Web Component Attribute Data-Binding crashing the Contact Manager sample
11
+
12
+ ## 0.6.11
13
+
14
+ - Set component attribute as a property in the Glimmer DSL by nesting 'propname value' inside component in consuming code
15
+ - Glimmer Web Component Attribute Data-Binding (by nesting data-binding declarations within consumed components)
16
+
3
17
  ## 0.6.10
4
18
 
5
19
  - Support Component Attribute Listeners including non-option attributes (like method-based attributes not generated by `option :someoption` like `attr_accessor :someattr`)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.6.10 (Beta)
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.7.0 (Beta)
2
2
  ## Ruby-in-the-Browser Web Frontend Framework
3
3
  ### The "Rails" of Frontend Frameworks!!! ([Fukuoka Award Winning](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html))
4
4
  #### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
@@ -1408,7 +1408,7 @@ rails new glimmer_app_server
1408
1408
  Add the following to `Gemfile`:
1409
1409
 
1410
1410
  ```
1411
- gem 'glimmer-dsl-web', '~> 0.6.10'
1411
+ gem 'glimmer-dsl-web', '~> 0.7.0'
1412
1412
  ```
1413
1413
 
1414
1414
  Run:
@@ -2977,6 +2977,8 @@ Component listeners enable consumers of components to listen to any custom event
2977
2977
 
2978
2978
  For example, an `AccordionSection` component might generate events `:expanded` and `:collapsed` when a user clicks on the section title to expand it or collapse it. Consumers can then use `on_expanded` and `on_collapsed` to listen to those events.
2979
2979
 
2980
+ Also, it is possible to listen to any component attribute by nesting `on_some_attribute_update`. And, it is possible to set component attributes by nesting `some_attribute value` or data-binding to them by nesting `some_attribute <=> [model, :attribute]`.
2981
+
2980
2982
  [lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb](/lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb)
2981
2983
 
2982
2984
  Glimmer HTML DSL Ruby code in the frontend:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.10
1
+ 0.7.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-web 0.6.10 ruby lib
5
+ # stub: glimmer-dsl-web 0.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-web".freeze
9
- s.version = "0.6.10"
9
+ s.version = "0.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Andy Maleh".freeze]
14
- s.date = "2025-02-23"
14
+ s.date = "2025-03-01"
15
15
  s.description = "Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework) enables building Web Frontends using Ruby in the Browser, as per Matz's recommendation in his RubyConf 2022 keynote speech to replace JavaScript with Ruby. It aims at providing the simplest, most intuitive, most straight-forward, and most productive frontend framework in existence. The framework follows the Ruby way (with DSLs and TIMTOWTDI) and the Rails way (Convention over Configuration) in building Isomorphic Ruby on Rails Applications. It provides a Ruby HTML DSL, which uniquely enables writing both structure code and logic code in one language. It supports both Unidirectional (One-Way) Data-Binding (using <=) and Bidirectional (Two-Way) Data-Binding (using <=>). Dynamic rendering (and re-rendering) of HTML content is also supported via Content Data-Binding. Modular design is supported with Glimmer Web Components, Component Slots, and Component Custom Event Listeners. And, a Ruby CSS DSL is supported with the included Glimmer DSL for CSS. Many samples are demonstrated in the Rails sample app (there is a very minimal Standalone [No Rails] sample app too). You can finally live in pure Rubyland on the Web in both the frontend and backend with Glimmer DSL for Web! This gem relies on Opal Ruby.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -7,7 +7,14 @@ module Glimmer
7
7
  module Web
8
8
  class PropertyExpression < Expression
9
9
  def can_interpret?(parent, keyword, *args, &block)
10
- parent.is_a?(Glimmer::Web::ElementProxy) and
10
+ # TODO add this condition once formatting elements become normal elements
11
+ # or delete this line if no longer needed:
12
+ # parent.is_a?(Glimmer::Web::FormattingElementProxy) ||
13
+ # Also, consider removing type check altogether (to generalize if good idea)
14
+ (
15
+ parent.is_a?(Glimmer::Web::ElementProxy) ||
16
+ parent.is_a?(Glimmer::Web::Component)
17
+ ) and
11
18
  (!args.empty?) and
12
19
  parent.respond_to?("#{keyword}=") and
13
20
  block.nil?
@@ -406,6 +406,7 @@ module Glimmer
406
406
  end
407
407
 
408
408
  def remove_observer(observer, attribute_or_event, options = {})
409
+ # TODO should we removing attribute observers? when removing component?
409
410
  if can_add_attribute_observer?(attribute_or_event)
410
411
  super(observer, attribute_or_event)
411
412
  elsif can_add_custom_event_listener?(attribute_or_event)
@@ -476,11 +477,24 @@ module Glimmer
476
477
  end
477
478
 
478
479
  def remove
480
+ remove_all_listeners
479
481
  @markup_root&.remove
480
482
  end
481
483
 
482
484
  def data_bind(property, model_binding)
483
- @markup_root&.data_bind(property, model_binding)
485
+ if has_option?(property) || (has_read_write_attribute?(property) && !@markup_root.respond_to?(property) && !@markup_root.respond_to?("#{property}="))
486
+ option_binding = Glimmer::DataBinding::ModelBinding.new(self, property)
487
+ #TODO make this options observer dependent and all similar observers in element specific data binding handlers
488
+ option_binding.observe(model_binding)
489
+ option_binding.call(model_binding.evaluate_property)
490
+ data_bindings[option_binding] = model_binding
491
+ if !model_binding.binding_options[:read_only]
492
+ model_binding.observe(option_binding)
493
+ model_binding.call(option_binding.evaluate_property)
494
+ end
495
+ else
496
+ @markup_root&.data_bind(property, model_binding)
497
+ end
484
498
  end
485
499
 
486
500
  def bind_content(*binding_args, &content_block)
@@ -508,6 +522,12 @@ module Glimmer
508
522
  end
509
523
  end
510
524
  end
525
+
526
+ def remove_all_listeners
527
+ data_bindings.each do |option_binding, model_binding|
528
+ option_binding.unregister_all_observables
529
+ end
530
+ end
511
531
 
512
532
  def method_missing(method_name, *args, &block)
513
533
  if can_handle_observation_request?(method_name)
@@ -556,6 +576,10 @@ module Glimmer
556
576
  def remove_style_block
557
577
  Glimmer::Web::Component.remove_component_style(self)
558
578
  end
579
+
580
+ def data_bindings
581
+ @data_bindings ||= {}
582
+ end
559
583
  end
560
584
  end
561
585
  end
@@ -140,6 +140,7 @@ module Glimmer
140
140
  'inner_html' => 'innerHTML',
141
141
  'outer_html' => 'outerHTML',
142
142
  }
143
+ CSS_CLASS_GLIMMER = 'glimmer'
143
144
  FORMAT_DATETIME = '%Y-%m-%dT%H:%M' # TODO ensure using when setting value on date/time fields without data-binding
144
145
  FORMAT_DATE = '%Y-%m-%d' # TODO ensure using when setting value on date/time fields without data-binding
145
146
  FORMAT_TIME = '%H:%M' # TODO ensure using when setting value on date/time fields without data-binding
@@ -515,7 +516,7 @@ module Glimmer
515
516
  # It is intentionally not set as the actual HTML element ID to let software engineers
516
517
  # specify their own IDs if they wanted
517
518
  def element_id
518
- @element_id ||= "element-#{ElementProxy.next_id_number_for(name)}"
519
+ @element_id ||= "#{CSS_CLASS_GLIMMER}-#{name}-#{ElementProxy.next_id_number_for(self.class.to_s)}"
519
520
  end
520
521
 
521
522
  def class_name=(*values)
@@ -1002,7 +1003,8 @@ module Glimmer
1002
1003
  private
1003
1004
 
1004
1005
  def base_css_classes
1005
- framework_css_classes = [name, element_id]
1006
+ framework_css_classes = @parent.nil? ? ["#{CSS_CLASS_GLIMMER}-root"] : []
1007
+ framework_css_classes += [element_id]
1006
1008
  if component
1007
1009
  framework_css_classes.prepend(component.class.component_element_class)
1008
1010
  framework_css_classes.prepend(component.class.component_shortcut_element_class) if component.class.component_shortcut_element_class != component.class.component_element_class
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-23 00:00:00.000000000 Z
11
+ date: 2025-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer