voom-presenters 2.0.0 → 2.1.2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.github/workflows/semantic-release.yml +5 -1
  4. data/.releaserc +17 -3
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +32 -15
  7. data/Gemfile +2 -1
  8. data/Gemfile.lock +15 -6
  9. data/README.md +14 -9
  10. data/app/demo/components/date_fields.pom +10 -0
  11. data/app/demo/components/multi_selects.pom +29 -0
  12. data/app/demo/components/nav/menu.pom +1 -0
  13. data/app/demo/components/selects.pom +2 -1
  14. data/app/demo/events/halted.pom +23 -0
  15. data/app/demo/events/nav/drawer.pom +1 -1
  16. data/app/demo/index.pom +5 -5
  17. data/app/demo/nav/top_nav.pom +3 -9
  18. data/{bin → exe}/presenters +0 -0
  19. data/lib/voom.rb +2 -2
  20. data/lib/voom/presenters/dsl/components/date_field.rb +13 -0
  21. data/lib/voom/presenters/dsl/components/datetime_base.rb +2 -1
  22. data/lib/voom/presenters/dsl/components/mixins/selects.rb +6 -0
  23. data/lib/voom/presenters/dsl/components/multi_select.rb +56 -0
  24. data/lib/voom/presenters/dsl/components/select.rb +0 -3
  25. data/lib/voom/presenters/version.rb +3 -1
  26. data/presenters.gemspec +2 -2
  27. data/public/bundle.css +85 -50
  28. data/public/bundle.js +1593 -1341
  29. data/public/wc.js +1186 -934
  30. data/views/mdc/assets/js/components/datetime.js +101 -18
  31. data/views/mdc/assets/js/components/events/posts.js +12 -11
  32. data/views/mdc/assets/js/components/initialize.js +2 -0
  33. data/views/mdc/assets/js/components/multi-select.js +75 -0
  34. data/views/mdc/assets/js/utils/form-data.js +12 -0
  35. data/views/mdc/assets/scss/app.scss +1 -0
  36. data/views/mdc/assets/scss/components/multi-select.scss +44 -0
  37. data/views/mdc/components/datetime.erb +7 -4
  38. data/views/mdc/components/multi_select.erb +33 -0
  39. data/views/mdc/package-lock.json +47 -33
  40. data/views/mdc/package.json +1 -1
  41. metadata +16 -10
  42. data/app/demo/component_status.pom +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60473475539018f69ad20f35699873f7d2412a03d587f593d4cbf6d779f4cb9e
4
- data.tar.gz: da650961c63ccf7eca6fff1c275704e7c771f733a539486f9042543da190e1bf
3
+ metadata.gz: 2d962ca9bae3f72f580876a97f077e2fe423366c3b60730eb15cf094f6ae4a1e
4
+ data.tar.gz: a82a320fe2aafbc3d72830755c7073f9f884d583ba434f894ca371c91fb0a6df
5
5
  SHA512:
6
- metadata.gz: b5973fda4ec9199af23a4272e6fa8ec64741d7af19411bd83ce260c58dae76b5ff604ed195d418d4833668caff6d372ecfaf137c1571f7a23c1bb6db3ae9b3b3
7
- data.tar.gz: 64e87d0ecea5a3ea847c08245e049cefadb3cc2c4162fc37c89bdb0d505f9260e00b1780bf88ed663f29cf4ce27b940913c54f70998b1cb74cd1060b297e5bdd
6
+ metadata.gz: 7da1eb176fdcced60b3b1126257c44a73968be7ab73da3a0df7f8e4bef7e15ffd7a46f2bdb5309ed274bf00453d671a35f87abcdf2714eab5093d7d2e9dd0cc4
7
+ data.tar.gz: 7fc9f46d3b6096f3cddd8ac6c0329211d433d4557c51d5466fe92379ff9128db7b0d908f099598f270d4e296b028326d55d540e7ba08276508e2f945d36af790
data/.circleci/config.yml CHANGED
@@ -7,7 +7,7 @@ jobs:
7
7
  build:
8
8
  docker:
9
9
  # specify the version you desire here
10
- - image: circleci/ruby:2.5.5-node-browsers
10
+ - image: circleci/ruby:2.7.2-node-browsers
11
11
 
12
12
  # Specify service dependencies here if necessary
13
13
  # CircleCI maintains a library of pre-built images
@@ -31,7 +31,11 @@ jobs:
31
31
  - name: Semantic Release
32
32
  uses: cycjimmy/semantic-release-action@v2
33
33
  with:
34
- extra_plugins: semantic-release-rubygem
34
+ extra_plugins: |
35
+ @semantic-release/git
36
+ @semantic-release/changelog
37
+ @semantic-release/github
38
+ semantic-release-rubygem
35
39
  dry_run: false
36
40
  env:
37
41
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
data/.releaserc CHANGED
@@ -1,8 +1,22 @@
1
1
  {
2
- "branches": ["master"],
2
+ "branches": ['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}],
3
3
  "plugins": [
4
4
  "@semantic-release/commit-analyzer",
5
5
  "@semantic-release/release-notes-generator",
6
- "semantic-release-rubygem"
6
+ "@semantic-release/release-notes-generator",
7
+ [
8
+ "@semantic-release/changelog",
9
+ {
10
+ "changelogFile": "CHANGELOG.md"
11
+ }
12
+ ],
13
+ [
14
+ "@semantic-release/git",
15
+ {
16
+ "assets": ["CHANGELOG.md"]
17
+ }
18
+ ],
19
+ "@semantic-release/github",
20
+ "semantic-release-rubygem"
7
21
  ]
8
- }
22
+ }
data/.ruby-version CHANGED
@@ -1,2 +1,2 @@
1
- 2.5.5
1
+ 2.7.2
2
2
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [2.1.2](https://github.com/rx/presenters/compare/v2.1.1...v2.1.2) (2021-06-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add Rack > 2.2.2 support ([6e23287](https://github.com/rx/presenters/commit/6e232875d1ea3c4250f9e19e841215a750082ffc))
7
+
8
+
9
+
10
+
11
+
12
+ ## [2.1.2](https://github.com/rx/presenters/compare/v2.1.1...v2.1.2) (2021-06-18)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * add Rack > 2.2.2 support ([6e23287](https://github.com/rx/presenters/commit/6e232875d1ea3c4250f9e19e841215a750082ffc))
18
+
1
19
  # Changelog
2
20
 
3
21
  ## [1.0.0](https://github.com/rx/presenters/tree/1.0.0) (2020-12-20)
@@ -117,20 +135,19 @@ This is the manual changelog, managed before switching to github_changelog_gener
117
135
 
118
136
  [Unreleased]: https://github.com/rx/presenters/compare/v0.1.14...HEAD
119
137
  [0.1.14]: https://github.com/rx/presenters/compare/v0.1.14...v0.1.13
120
- [Namespaces]: https://powerful-bastion-96181.herokuapp.com/namespaces
121
- [Stepper]: https://powerful-bastion-96181.herokuapp.com/steppers
122
- [Rich text component]: https://powerful-bastion-96181.herokuapp.com/text_areas
123
- [Slider component]: https://powerful-bastion-96181.herokuapp.com/sliders
124
- [Tagged Input]: https://powerful-bastion-96181.herokuapp.com/tagged_input
125
- [Overline Text Style]: https://powerful-bastion-96181.herokuapp.com/styles
126
- [Page separator]: https://powerful-bastion-96181.herokuapp.com/separator
127
- [Blank lines]: https://powerful-bastion-96181.herokuapp.com/styles
128
- [Grid Padding]: https://powerful-bastion-96181.herokuapp.com/layouts
129
- [Map component]: https://powerful-bastion-96181.herokuapp.com/maps
130
- [Clear action]: https://powerful-bastion-96181.herokuapp.com/clear_action
131
- [Chip as input]: https://powerful-bastion-96181.herokuapp.com/chips#input_chips
132
- [Floating content blocks]:https://powerful-bastion-96181.herokuapp.com/content#floating
133
- [Grid Wide/Table scrolling]:https://powerful-bastion-96181.herokuapp.com/tables
134
-
138
+ [Namespaces]: https://coprl-ruby.herokuapp.com/namespaces
139
+ [Stepper]: https://coprl-ruby.herokuapp.com/steppers
140
+ [Rich text component]: https://coprl-ruby.herokuapp.com/text_areas
141
+ [Slider component]: https://coprl-ruby.herokuapp.com/sliders
142
+ [Tagged Input]: https://coprl-ruby.herokuapp.com/tagged_input
143
+ [Overline Text Style]: https://coprl-ruby.herokuapp.com/styles
144
+ [Page separator]: https://coprl-ruby.herokuapp.com/separator
145
+ [Blank lines]: https://coprl-ruby.herokuapp.com/styles
146
+ [Grid Padding]: https://coprl-ruby.herokuapp.com/layouts
147
+ [Map component]: https://coprl-ruby.herokuapp.com/maps
148
+ [Clear action]: https://coprl-ruby.herokuapp.com/clear_action
149
+ [Chip as input]: https://coprl-ruby.herokuapp.com/chips#input_chips
150
+ [Floating content blocks]:https://coprl-ruby.herokuapp.com/content#floating
151
+ [Grid Wide/Table scrolling]:https://coprl-ruby.herokuapp.com/tables
135
152
 
136
153
  \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- ruby `cat .ruby-version`
4
+ ruby `[ -z "$RBENV_VERSION" ] && cat .ruby-version || echo $RBENV_VERSION`
5
5
  # Specify your gem's dependencies in voom-console.gemspec
6
6
  gemspec
7
7
 
@@ -22,3 +22,4 @@ gem 'image_crop_presenter_plugin', github:'rx/image_crop_presenter_plugin'
22
22
  gem 'chart_presenter_plugin', github:'rx/chart_presenter_plugin'
23
23
  gem 'rack-cors'
24
24
  gem 'honeybadger' if ENV.fetch('HONEYBADGER_API_KEY'){false}
25
+ gem 'puma'
data/Gemfile.lock CHANGED
@@ -56,15 +56,22 @@ GEM
56
56
  ice_nine (0.11.2)
57
57
  json (2.3.1)
58
58
  method_source (0.9.0)
59
- mini_portile2 (2.4.0)
59
+ mini_portile2 (2.5.1)
60
60
  mustermann (1.1.1)
61
61
  ruby2_keywords (~> 0.0.1)
62
- nokogiri (1.10.9)
63
- mini_portile2 (~> 2.4.0)
62
+ nio4r (2.5.7)
63
+ nokogiri (1.11.4)
64
+ mini_portile2 (~> 2.5.0)
65
+ racc (~> 1.4)
66
+ nokogiri (1.11.4-x86_64-darwin)
67
+ racc (~> 1.4)
64
68
  optimist (3.0.1)
65
69
  pry (0.11.3)
66
70
  coderay (~> 1.1.0)
67
71
  method_source (~> 0.9.0)
72
+ puma (5.3.1)
73
+ nio4r (~> 2.0)
74
+ racc (1.5.2)
68
75
  rack (2.2.3)
69
76
  rack-cors (1.1.0)
70
77
  rack (>= 2.0.0)
@@ -130,14 +137,16 @@ GEM
130
137
 
131
138
  PLATFORMS
132
139
  ruby
140
+ x86_64-darwin-19
133
141
 
134
142
  DEPENDENCIES
135
- bundler (~> 1.13)
143
+ bundler (>= 1.13)
136
144
  chart_presenter_plugin!
137
145
  foo_presenter_plugin!
138
146
  gem-release (~> 2.0)
139
147
  image_crop_presenter_plugin!
140
148
  pry
149
+ puma
141
150
  rack (>= 2.0.6)
142
151
  rack-cors
143
152
  rack-test (~> 0.8)
@@ -154,7 +163,7 @@ DEPENDENCIES
154
163
  webdrivers (~> 4.1)
155
164
 
156
165
  RUBY VERSION
157
- ruby 2.5.5p157
166
+ ruby 2.7.2p137
158
167
 
159
168
  BUNDLED WITH
160
- 1.17.3
169
+ 2.2.20
data/README.md CHANGED
@@ -1,21 +1,19 @@
1
- # Voom::Presenters
1
+ # COmmon PResenter Language (COPRL)
2
+
3
+ ![alt text](https://media.giphy.com/media/13LEyaRbQbiWdi/giphy.gif "Power Washer for Building User Interfaces")
2
4
 
3
5
  ## TLDR;
4
- Do you wish you could write a modern user interface in pure Ruby?
6
+ Do you wish you could write a modern user interface in Ruby?
5
7
 
6
8
  Now you can. Presenters are a Ruby DSL for rendering user interfaces.
7
- The semantics are adopted from [Material Design](https://material.io/).
8
9
 
10
+ * Presenters are a power washer for building user interfaces
9
11
  * Presenters are to HTML/User Interfaces what C is to assembly
10
12
  * A presenter generates a Presenter Object Model (POM)
11
13
  * A POM fully describes a user interface
12
14
  * A POM client can fully render user interface from POM
13
15
 
14
- ## What are voom-presenters?
15
-
16
- * A Ruby user interface abstraction
17
- * A Ruby DSL to build a user interface
18
- * A power washer for building user interfaces
16
+ The semantics are adopted from [Material Design](https://material.io/).
19
17
 
20
18
  ## Why?
21
19
 
@@ -39,7 +37,7 @@ This concept was initially inspired by the Presenters concepts of Ivar Jacobson
39
37
 
40
38
  ## Demo
41
39
 
42
- [Demo]
40
+ [Demo](https://coprl-ruby.herokuapp.com/)
43
41
 
44
42
  Or to run locally:
45
43
 
@@ -49,6 +47,13 @@ Or to run locally:
49
47
  bundle exec rackup
50
48
 
51
49
  open http://localhost:9292
50
+
51
+ > Note: Demo defaults to Ruby version 2.7.3 in the .ruby-version file. If you want to run a different version
52
+ > -- set RBENV_VERSION to your desired version.
53
+ > For example:
54
+ > ```
55
+ > RBENV_VERSION=2.5.5 bundle insatall
56
+ > RBENV_VERSION=2.5.5 bundle exec rackup```
52
57
 
53
58
  To see the POM:
54
59
 
@@ -91,6 +91,16 @@ Voom::Presenters.define(:date_fields) do
91
91
  end
92
92
  end
93
93
 
94
+ grid do
95
+ column 6 do
96
+ title 'As a simple text field'
97
+ text 'You can use the date field without a picker and get a simple auto-formatting text input.'
98
+ date_field picker: false do
99
+ label 'Birthdate'
100
+ end
101
+ end
102
+ end
103
+
94
104
  end
95
105
  attach :code, file: __FILE__
96
106
  end
@@ -0,0 +1,29 @@
1
+ require_relative '../helpers/indented_grid'
2
+
3
+ Voom::Presenters.define(:multi_selects) do
4
+ helpers Demo::Helpers::IndentedGrid
5
+ attach :top_nav
6
+ attach :component_drawer
7
+ page_title 'Multi Select Fields'
8
+
9
+ indented_grid do
10
+ content do
11
+ multi_select do
12
+ label 'Multi Select Field'
13
+ check_option value: 'value1', text: 'First value', selected: true
14
+ check_option value: 'value2', text: 'Second value', selected: true
15
+ check_option value: 'value3', text: 'Third value', selected: true
16
+ end
17
+
18
+ multi_select do
19
+ label 'One Selection'
20
+ check_option value: 'value1', text: 'First value', selected: true
21
+ check_option value: 'value2', text: 'Second value', selected: false
22
+ check_option value: 'value3', text: 'Third value', selected: false
23
+ end
24
+
25
+ end
26
+
27
+ attach :code, file: __FILE__
28
+ end
29
+ end
@@ -27,6 +27,7 @@ Voom::Presenters.define('component_menu') do
27
27
  number_fields
28
28
  maps
29
29
  menus
30
+ multi_selects
30
31
  progress
31
32
  selects
32
33
  sliders
@@ -26,7 +26,8 @@ Voom::Presenters.define(:selects) do
26
26
 
27
27
  select outlined: false do
28
28
  label 'Alternate style ...'
29
- option do
29
+ option
30
+ option selected: true do
30
31
  value 'value1'
31
32
  text 'First value'
32
33
  end
@@ -0,0 +1,23 @@
1
+ Voom::Presenters.define(:halted) do
2
+ helpers Demo::Helpers::IndentedGrid
3
+ attach :top_nav
4
+ attach :events_drawer
5
+
6
+ indented_grid do
7
+ display 'Halted Events'
8
+ body 'This demonstrates how to respond to failed, or halted events'
9
+
10
+ content do
11
+ button :failed_post do
12
+ event :click do
13
+ posts '_echo_', status: 500
14
+ end
15
+ event 'V:eventsHalted' do
16
+ snackbar 'That did not work! Please try again later.'
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ attach :code, file: __FILE__
23
+ end
@@ -1,7 +1,7 @@
1
1
  Voom::Presenters.define(:events_drawer) do
2
2
  helpers Voom::Presenters::Helpers::Inflector
3
3
 
4
- events = %i[field_level_events form_level_events tagged_input parallel_events].sort
4
+ events = %i[field_level_events form_level_events tagged_input parallel_events halted].sort
5
5
  actions = %i[dialog replaces loads toggle_visibility snackbar updates deletes posts clear last_response prompt_if_dirty].sort
6
6
 
7
7
  drawer 'Events' do
data/app/demo/index.pom CHANGED
@@ -5,16 +5,16 @@ Voom::Presenters.define(:index) do
5
5
  attach :top_nav
6
6
 
7
7
  indented_grid do
8
- headline 'Presenters', id: :headline
9
- subheading 'Presenters are to HTML what C is to assembly'
8
+ headline 'COmmon PResenter Language (COPRL) Ruby Demo - AKA Presenters', id: :headline
9
+ subheading 'COPRL is to HTML what C is to assembly'
10
10
 
11
- body ['A presenter describes a user interface using a ruby DSL.',
12
- 'The presenter is evaluated and a presenter object model (POM) is generated.',
11
+ body ['A presenter describes a user interface using DSL.',
12
+ 'The presenter is evaluated and a presenter object model (POM) is generated. The POM can be serialized as JSON.',
13
13
  'A client that renders POM can display the given user interface.']
14
14
 
15
15
  body 'To get started checkout the components and events.'
16
16
 
17
- subheading 'For example this is the presenter dsl for this page:', level: 2
17
+ subheading 'For example this is the complete presenter DSL for this page:', level: 2
18
18
 
19
19
  source = File.read(__FILE__)
20
20
  body <<~HEREDOC
@@ -1,9 +1,10 @@
1
1
  Voom::Presenters.define('top_nav') do
2
+ TITLE = 'COmmon PResenters Language (COPRL) Ruby Demo'
2
3
  page do
3
- title 'Presenters Demo'
4
+ title TITLE
4
5
  end
5
6
 
6
- header 'Presenters Demo' do
7
+ header TITLE do
7
8
  nav do
8
9
  item 'About' do
9
10
  event :click do
@@ -52,13 +53,6 @@ Voom::Presenters.define('top_nav') do
52
53
  loads :plugins
53
54
  end
54
55
  end
55
-
56
- item 'Status' do
57
- event :click do
58
- loads :component_status
59
- end
60
- end
61
-
62
56
  end
63
57
  end
64
58
  end
File without changes
data/lib/voom.rb CHANGED
@@ -20,6 +20,6 @@ module Voom
20
20
  end
21
21
 
22
22
  if defined?(::Rails)
23
- # loader.logger = Rails.logger
24
- load 'voom/railtie.rb'
23
+ # We need this class's file to be parsed, but we want to let Zeitwerk load it
24
+ Voom::Railtie
25
25
  end
@@ -5,14 +5,27 @@ module Voom
5
5
  module DSL
6
6
  module Components
7
7
  class DateField < DatetimeBase
8
+ DEFAULT_HINT = 'Enter date as MM/DD/YYYY'
9
+ DEFAULT_ERROR = "Invalid date. #{DEFAULT_HINT}"
10
+
8
11
  attr_reader :config
9
12
 
10
13
  def initialize(**attribs_, &block)
11
14
  super(type: :date, **attribs_, &block)
12
15
  merge_config(:min_date)
13
16
  merge_config(:max_date)
17
+ unless @picker
18
+ @hint ||= DEFAULT_HINT
19
+ @validation_error ||= DEFAULT_ERROR
20
+ end
14
21
  expand!
15
22
  end
23
+
24
+ def validation_error(error=nil)
25
+ return @validation_error if locked?
26
+ @validation_error ||= error
27
+ end
28
+
16
29
  end
17
30
  end
18
31
  end
@@ -3,7 +3,7 @@ module Voom
3
3
  module DSL
4
4
  module Components
5
5
  class DatetimeBase < TextField
6
- attr_reader :config
6
+ attr_reader :config, :picker
7
7
 
8
8
  def initialize(**attribs_, &block)
9
9
  super(**attribs_, &block)
@@ -12,6 +12,7 @@ module Voom
12
12
  merge_config(:disable)
13
13
  merge_config(:enable)
14
14
  merge_config(:mode)
15
+ @picker = attribs_.delete(:picker){ true }
15
16
 
16
17
  my_id = self.id
17
18
  clear_icon(:clear) do