headmin 0.3.4 → 0.4.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/.github/workflows/ci.yml +27 -0
- data/.gitignore +14 -0
- data/.nvmrc +1 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +171 -3
- data/README.md +7 -0
- data/Rakefile +1 -7
- data/app/assets/javascripts/headmin/config/i18n.js +9 -9
- data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -0
- data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
- data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
- data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
- data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
- data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
- data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
- data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
- data/app/assets/javascripts/headmin/controllers/popup_controller.js +51 -52
- data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
- data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
- data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +100 -101
- data/app/assets/javascripts/headmin/controllers/table_controller.js +115 -115
- data/app/assets/javascripts/headmin/index.js +38 -35
- data/app/assets/javascripts/headmin.js +243 -34
- data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
- data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
- data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
- data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
- data/app/assets/stylesheets/headmin/forms.scss +11 -0
- data/app/assets/stylesheets/headmin/general.scss +5 -0
- data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
- data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
- data/app/assets/stylesheets/headmin/popup.scss +1 -0
- data/app/assets/stylesheets/headmin/syntax.scss +36 -349
- data/app/assets/stylesheets/headmin/table.scss +1 -1
- data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
- data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
- data/app/assets/stylesheets/headmin/utilities.scss +2 -68
- data/app/assets/stylesheets/headmin.css +205 -205
- data/app/assets/stylesheets/headmin.scss +1 -1
- data/app/helpers/headmin/admin_helper.rb +0 -1
- data/app/helpers/headmin/form_helper.rb +2 -8
- data/app/models/concerns/headmin/blockable.rb +1 -1
- data/app/models/concerns/headmin/field.rb +1 -0
- data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
- data/app/models/concerns/headmin/form/hintable.rb +19 -0
- data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
- data/app/models/concerns/headmin/form/labelable.rb +33 -0
- data/app/models/concerns/headmin/form/listable.rb +28 -0
- data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
- data/app/models/concerns/headmin/form/validatable.rb +40 -0
- data/app/models/concerns/headmin/form/wrappable.rb +21 -0
- data/app/models/headmin/.DS_Store +0 -0
- data/app/models/headmin/blocks_view.rb +15 -0
- data/app/models/headmin/form/blocks_view.rb +29 -0
- data/app/models/headmin/form/checkbox_view.rb +52 -0
- data/app/models/headmin/form/date_range_view.rb +25 -0
- data/app/models/headmin/form/date_view.rb +45 -0
- data/app/models/headmin/form/email_view.rb +48 -0
- data/app/models/headmin/form/file_view.rb +116 -0
- data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
- data/app/models/headmin/form/flatpickr_view.rb +37 -0
- data/app/models/headmin/form/hidden_view.rb +10 -0
- data/app/models/headmin/form/hint_view.rb +6 -0
- data/app/models/headmin/form/input_group_view.rb +19 -0
- data/app/models/headmin/form/label_view.rb +24 -0
- data/app/models/headmin/form/number_view.rb +49 -0
- data/app/models/headmin/form/password_view.rb +44 -0
- data/app/models/headmin/form/redactorx_view.rb +59 -0
- data/app/models/headmin/form/search_view.rb +48 -0
- data/app/models/headmin/form/select_view.rb +62 -0
- data/app/models/headmin/form/switch_view.rb +23 -0
- data/app/models/headmin/form/text_view.rb +48 -0
- data/app/models/headmin/form/textarea_view.rb +44 -0
- data/app/models/headmin/form/url_view.rb +48 -0
- data/app/models/headmin/form/wrapper_view.rb +19 -0
- data/app/models/headmin/form/wysiwyg_view.rb +17 -0
- data/app/models/headmin/{thumbnail.rb → thumbnail_view.rb} +6 -1
- data/app/models/view_model.rb +58 -0
- data/app/views/headmin/_blocks.html.erb +13 -9
- data/app/views/headmin/_heading.html.erb +7 -1
- data/app/views/headmin/_thumbnail.html.erb +1 -37
- data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
- data/app/views/headmin/forms/_blocks.html.erb +16 -17
- data/app/views/headmin/forms/_checkbox.html.erb +24 -29
- data/app/views/headmin/forms/_datalist.html.erb +3 -0
- data/app/views/headmin/forms/_date.html.erb +24 -24
- data/app/views/headmin/forms/_date_range.html.erb +19 -21
- data/app/views/headmin/forms/_email.html.erb +27 -32
- data/app/views/headmin/forms/_errors.html.erb +2 -3
- data/app/views/headmin/forms/_file.html.erb +84 -181
- data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
- data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
- data/app/views/headmin/forms/_hidden.html.erb +9 -10
- data/app/views/headmin/forms/_hint.html.erb +16 -0
- data/app/views/headmin/forms/_input_group.html.erb +21 -0
- data/app/views/headmin/forms/_label.html.erb +5 -13
- data/app/views/headmin/forms/_number.html.erb +23 -35
- data/app/views/headmin/forms/_password.html.erb +21 -30
- data/app/views/headmin/forms/_redactorx.html.erb +21 -40
- data/app/views/headmin/forms/_repeater.html.erb +55 -60
- data/app/views/headmin/forms/_search.html.erb +43 -0
- data/app/views/headmin/forms/_select.html.erb +24 -49
- data/app/views/headmin/forms/_switch.html.erb +29 -0
- data/app/views/headmin/forms/_text.html.erb +42 -96
- data/app/views/headmin/forms/_textarea.html.erb +21 -32
- data/app/views/headmin/forms/_url.html.erb +26 -31
- data/app/views/headmin/forms/_validation.html.erb +10 -13
- data/app/views/headmin/forms/_wrapper.html.erb +9 -0
- data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
- data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
- data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
- data/app/views/headmin/forms/fields/_group.html.erb +5 -3
- data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
- data/bin/console +0 -1
- data/config/locales/headmin/forms/en.yml +0 -11
- data/config/locales/headmin/forms/nl.yml +0 -11
- data/esbuild-css.js +18 -18
- data/esbuild-js.js +8 -8
- data/headmin.gemspec +1 -3
- data/lib/generators/templates/controllers/auth/confirmations_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +0 -2
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +0 -2
- data/lib/headmin/version.rb +1 -3
- data/lib/headmin.rb +0 -2
- data/package-lock.json +5359 -0
- data/package.json +12 -4
- data/view_model_benchmark.rb +74 -0
- data/yarn-error.log +17 -12
- data/yarn.lock +1575 -31
- metadata +62 -24
- data/app/assets/stylesheets/headmin/form.scss +0 -132
- data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
- data/app/helpers/headmin/documentation_helper.rb +0 -35
- data/app/models/headmin/documentation_renderer.rb +0 -32
- data/app/models/headmin/form/base.rb +0 -78
- data/app/models/headmin/form/text.rb +0 -51
- data/app/services/block_service.rb +0 -72
- data/app/views/headmin/_card.html.erb +0 -52
- data/app/views/headmin/forms/_actions.html.erb +0 -28
- data/app/views/headmin/forms/_base.html.erb +0 -114
- data/app/views/headmin/forms/_image.html.erb +0 -21
- data/app/views/headmin/forms/_video.html.erb +0 -21
- data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
- data/app/views/headmin/forms/actions/_save.html.erb +0 -12
- data/app/views/headmin/forms/actions/_view.html.erb +0 -15
- data/docs/blocks-and-fields.md +0 -54
- data/docs/blocks.md +0 -48
- data/docs/devise.md +0 -41
- data/docs/fields.md +0 -79
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b427a7de1334a6a27a66b145247d4d09379f25c446e01ff87bb17e46fb6098c6
|
4
|
+
data.tar.gz: bda5b5c568a4872ce1be8e2da62a10d801370967c5beffed0ff27eb12576d407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b0363d0ee6aec32484806ef1e655d681127ae1318f0e391585f81d97b7cce1f28af1368c9038570a28aa0333abfafbc59dbcc65de49862f8248ff2a574edd83
|
7
|
+
data.tar.gz: 4aaaff3a6a1550829bd10e4af436fc6a5bc0515ff6098b1b6761e577365b5816c0bbea2d65e3c2bee1633944a10890079cdb34a263998524e1adaf45e5887df0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- '*'
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
runs-on: ubuntu-20.04
|
13
|
+
steps:
|
14
|
+
- name: Install libvips
|
15
|
+
run: sudo apt-get install -y libvips
|
16
|
+
- uses: actions/checkout@master
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
bundler: default
|
21
|
+
bundler-cache: true
|
22
|
+
- name: StandardRb check
|
23
|
+
run: bundle exec standardrb
|
24
|
+
- name: Run tests
|
25
|
+
env:
|
26
|
+
RAILS_ENV: test
|
27
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
@@ -8,6 +8,20 @@
|
|
8
8
|
/tmp/
|
9
9
|
/node_modules/
|
10
10
|
|
11
|
+
# Ignore dummy app
|
12
|
+
/test/dummy/log/*
|
13
|
+
/test/dummy/tmp/*
|
14
|
+
/test/dummy/db/*.sqlite3
|
15
|
+
/test/dummy/db/*.sqlite3-*
|
16
|
+
!/test/dummy/log/.keep
|
17
|
+
!/test/dummy/tmp/.keep
|
18
|
+
/test/dummy/tmp/pids/*
|
19
|
+
!/test/dummy/tmp/pids/
|
20
|
+
!/test/dummy/tmp/pids/.keep
|
21
|
+
/test/dummy/storage/*
|
22
|
+
!/test/dummy/storage/.keep
|
23
|
+
/test/dummy/public/assets
|
24
|
+
|
11
25
|
# Ingore editors
|
12
26
|
/.idea
|
13
27
|
/headmin.iml
|
data/.nvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lts/gallium
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Headmin Changelog
|
2
2
|
|
3
|
+
## HEAD
|
4
|
+
- FEATURE: Introduction of a `ViewModel` class to clean up the component views. This allows for a cleaner abstraction and better testing.
|
5
|
+
- FEATURE: New `wysiwyg` component which currently defaults to Redactor X. Redactor X will be swapped with a free open source version in the 1.0 release.
|
6
|
+
- FEATURE: `headmin/forms/redactorx` now accepts `hybrid: true` to hide the controls
|
7
|
+
- FEATURE: `headmin/forms/wysiwyg` accepts a `toolbar: false` to thide the top toolbar
|
8
|
+
- FEATURE: Validation highlighting has been added to all form fields
|
9
|
+
- FEATURE: Autocomplete suggestions added to `headmin/forms/text`, `headmin/forms/url`, `headmin/forms/email` and `headmin/forms/search`
|
10
|
+
- FIX: Readonly inputs didn't show the default greyed out background color
|
11
|
+
- FIX: Top corners of repeaters were square
|
12
|
+
- FIX: Square corners on group fields are now round
|
13
|
+
- BREAK: Passing the names of the blocks in `headmin/forms/blocks` is now required. The `allow` parameter is deprecated in favor of `names`.
|
14
|
+
- BREAK: `headmin/card` has been removed
|
15
|
+
- BREAK: `headmin/forms/actions` and all of its child components have been removed
|
16
|
+
- BREAK: `$font-weight-medium` has been removed from headmin overrides variables. We don't want to introduce new variable names that look like they are part of Bootstrap.
|
17
|
+
- BREAK: `headmin/forms/date_range` has a different way of setting attribute specific values. We now have a `:start` and `:end` attribute that accept all possible input options for their respective inputs. Both have a required `:attribute` parameter now.
|
18
|
+
|
19
|
+
```erb
|
20
|
+
# Old
|
21
|
+
<%= render "headmin/forms/date_range", form: form, start_attribute: :start_date, end_attribute: :end_date %>
|
22
|
+
|
23
|
+
# New
|
24
|
+
<%= render "headmin/forms/date_range", form: form, start: {attribute: :start_date}, end: {attribute: :end_date} %>
|
25
|
+
```
|
26
|
+
|
3
27
|
## 0.3
|
4
28
|
|
5
29
|
- Support for import maps added
|
data/Gemfile
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
source "https://rubygems.org"
|
4
2
|
|
5
3
|
# Specify your gem's dependencies in headmin.gemspec
|
6
4
|
gemspec
|
7
5
|
|
8
|
-
gem "
|
9
|
-
|
6
|
+
gem "capybara", ">= 3.26"
|
10
7
|
gem "minitest", "~> 5.0"
|
8
|
+
gem "minitest-spec-rails", "~> 6.1"
|
9
|
+
gem "rails", "~> 7.0"
|
10
|
+
gem "rake", "~> 13.0"
|
11
|
+
gem "sprockets-rails", "~> 3.4"
|
12
|
+
gem "sqlite3", "~> 1.4"
|
11
13
|
gem "standard", "~> 1.7"
|
14
|
+
gem "debug"
|
data/Gemfile.lock
CHANGED
@@ -1,48 +1,191 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
headmin (0.3.
|
4
|
+
headmin (0.3.4)
|
5
5
|
closure_tree (~> 7.4)
|
6
6
|
inline_svg (~> 1.7)
|
7
7
|
redcarpet (~> 3.5)
|
8
|
-
rouge (~> 3.
|
8
|
+
rouge (~> 3.28)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
+
actioncable (7.0.1)
|
14
|
+
actionpack (= 7.0.1)
|
15
|
+
activesupport (= 7.0.1)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
actionmailbox (7.0.1)
|
19
|
+
actionpack (= 7.0.1)
|
20
|
+
activejob (= 7.0.1)
|
21
|
+
activerecord (= 7.0.1)
|
22
|
+
activestorage (= 7.0.1)
|
23
|
+
activesupport (= 7.0.1)
|
24
|
+
mail (>= 2.7.1)
|
25
|
+
net-imap
|
26
|
+
net-pop
|
27
|
+
net-smtp
|
28
|
+
actionmailer (7.0.1)
|
29
|
+
actionpack (= 7.0.1)
|
30
|
+
actionview (= 7.0.1)
|
31
|
+
activejob (= 7.0.1)
|
32
|
+
activesupport (= 7.0.1)
|
33
|
+
mail (~> 2.5, >= 2.5.4)
|
34
|
+
net-imap
|
35
|
+
net-pop
|
36
|
+
net-smtp
|
37
|
+
rails-dom-testing (~> 2.0)
|
38
|
+
actionpack (7.0.1)
|
39
|
+
actionview (= 7.0.1)
|
40
|
+
activesupport (= 7.0.1)
|
41
|
+
rack (~> 2.0, >= 2.2.0)
|
42
|
+
rack-test (>= 0.6.3)
|
43
|
+
rails-dom-testing (~> 2.0)
|
44
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
45
|
+
actiontext (7.0.1)
|
46
|
+
actionpack (= 7.0.1)
|
47
|
+
activerecord (= 7.0.1)
|
48
|
+
activestorage (= 7.0.1)
|
49
|
+
activesupport (= 7.0.1)
|
50
|
+
globalid (>= 0.6.0)
|
51
|
+
nokogiri (>= 1.8.5)
|
52
|
+
actionview (7.0.1)
|
53
|
+
activesupport (= 7.0.1)
|
54
|
+
builder (~> 3.1)
|
55
|
+
erubi (~> 1.4)
|
56
|
+
rails-dom-testing (~> 2.0)
|
57
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
58
|
+
activejob (7.0.1)
|
59
|
+
activesupport (= 7.0.1)
|
60
|
+
globalid (>= 0.3.6)
|
13
61
|
activemodel (7.0.1)
|
14
62
|
activesupport (= 7.0.1)
|
15
63
|
activerecord (7.0.1)
|
16
64
|
activemodel (= 7.0.1)
|
17
65
|
activesupport (= 7.0.1)
|
66
|
+
activestorage (7.0.1)
|
67
|
+
actionpack (= 7.0.1)
|
68
|
+
activejob (= 7.0.1)
|
69
|
+
activerecord (= 7.0.1)
|
70
|
+
activesupport (= 7.0.1)
|
71
|
+
marcel (~> 1.0)
|
72
|
+
mini_mime (>= 1.1.0)
|
18
73
|
activesupport (7.0.1)
|
19
74
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
75
|
i18n (>= 1.6, < 2)
|
21
76
|
minitest (>= 5.1)
|
22
77
|
tzinfo (~> 2.0)
|
78
|
+
addressable (2.8.0)
|
79
|
+
public_suffix (>= 2.0.2, < 5.0)
|
23
80
|
ast (2.4.2)
|
81
|
+
builder (3.2.4)
|
82
|
+
capybara (3.36.0)
|
83
|
+
addressable
|
84
|
+
matrix
|
85
|
+
mini_mime (>= 0.1.3)
|
86
|
+
nokogiri (~> 1.8)
|
87
|
+
rack (>= 1.6.0)
|
88
|
+
rack-test (>= 0.6.3)
|
89
|
+
regexp_parser (>= 1.5, < 3.0)
|
90
|
+
xpath (~> 3.2)
|
24
91
|
closure_tree (7.4.0)
|
25
92
|
activerecord (>= 4.2.10)
|
26
93
|
with_advisory_lock (>= 4.0.0)
|
27
94
|
concurrent-ruby (1.1.9)
|
95
|
+
crass (1.0.6)
|
96
|
+
debug (1.4.0)
|
97
|
+
irb (>= 1.3.6)
|
98
|
+
reline (>= 0.2.7)
|
99
|
+
digest (3.1.0)
|
100
|
+
erubi (1.10.0)
|
101
|
+
globalid (1.0.0)
|
102
|
+
activesupport (>= 5.0)
|
28
103
|
i18n (1.9.1)
|
29
104
|
concurrent-ruby (~> 1.0)
|
30
105
|
inline_svg (1.8.0)
|
31
106
|
activesupport (>= 3.0)
|
32
107
|
nokogiri (>= 1.6)
|
108
|
+
io-console (0.5.11)
|
109
|
+
io-wait (0.2.1)
|
110
|
+
irb (1.4.1)
|
111
|
+
reline (>= 0.3.0)
|
112
|
+
loofah (2.13.0)
|
113
|
+
crass (~> 1.0.2)
|
114
|
+
nokogiri (>= 1.5.9)
|
115
|
+
mail (2.7.1)
|
116
|
+
mini_mime (>= 0.1.1)
|
117
|
+
marcel (1.0.2)
|
118
|
+
matrix (0.4.2)
|
119
|
+
method_source (1.0.0)
|
120
|
+
mini_mime (1.1.2)
|
33
121
|
minitest (5.14.4)
|
122
|
+
minitest-spec-rails (6.1.0)
|
123
|
+
minitest (>= 5.0)
|
124
|
+
railties (>= 4.1)
|
125
|
+
net-imap (0.2.3)
|
126
|
+
digest
|
127
|
+
net-protocol
|
128
|
+
strscan
|
129
|
+
net-pop (0.1.1)
|
130
|
+
digest
|
131
|
+
net-protocol
|
132
|
+
timeout
|
133
|
+
net-protocol (0.1.2)
|
134
|
+
io-wait
|
135
|
+
timeout
|
136
|
+
net-smtp (0.3.1)
|
137
|
+
digest
|
138
|
+
net-protocol
|
139
|
+
timeout
|
140
|
+
nio4r (2.5.8)
|
141
|
+
nokogiri (1.13.1-arm64-darwin)
|
142
|
+
racc (~> 1.4)
|
34
143
|
nokogiri (1.13.1-x86_64-darwin)
|
35
144
|
racc (~> 1.4)
|
145
|
+
nokogiri (1.13.1-x86_64-linux)
|
146
|
+
racc (~> 1.4)
|
36
147
|
parallel (1.21.0)
|
37
148
|
parser (3.1.0.0)
|
38
149
|
ast (~> 2.4.1)
|
150
|
+
public_suffix (4.0.6)
|
39
151
|
racc (1.6.0)
|
152
|
+
rack (2.2.3)
|
153
|
+
rack-test (1.1.0)
|
154
|
+
rack (>= 1.0, < 3)
|
155
|
+
rails (7.0.1)
|
156
|
+
actioncable (= 7.0.1)
|
157
|
+
actionmailbox (= 7.0.1)
|
158
|
+
actionmailer (= 7.0.1)
|
159
|
+
actionpack (= 7.0.1)
|
160
|
+
actiontext (= 7.0.1)
|
161
|
+
actionview (= 7.0.1)
|
162
|
+
activejob (= 7.0.1)
|
163
|
+
activemodel (= 7.0.1)
|
164
|
+
activerecord (= 7.0.1)
|
165
|
+
activestorage (= 7.0.1)
|
166
|
+
activesupport (= 7.0.1)
|
167
|
+
bundler (>= 1.15.0)
|
168
|
+
railties (= 7.0.1)
|
169
|
+
rails-dom-testing (2.0.3)
|
170
|
+
activesupport (>= 4.2.0)
|
171
|
+
nokogiri (>= 1.6)
|
172
|
+
rails-html-sanitizer (1.4.2)
|
173
|
+
loofah (~> 2.3)
|
174
|
+
railties (7.0.1)
|
175
|
+
actionpack (= 7.0.1)
|
176
|
+
activesupport (= 7.0.1)
|
177
|
+
method_source
|
178
|
+
rake (>= 12.2)
|
179
|
+
thor (~> 1.0)
|
180
|
+
zeitwerk (~> 2.5)
|
40
181
|
rainbow (3.1.1)
|
41
182
|
rake (13.0.3)
|
42
183
|
redcarpet (3.5.1)
|
43
184
|
regexp_parser (2.2.0)
|
185
|
+
reline (0.3.1)
|
186
|
+
io-console (~> 0.5)
|
44
187
|
rexml (3.2.5)
|
45
|
-
rouge (3.
|
188
|
+
rouge (3.28.0)
|
46
189
|
rubocop (1.25.0)
|
47
190
|
parallel (~> 1.10)
|
48
191
|
parser (>= 3.1.0.0)
|
@@ -58,22 +201,47 @@ GEM
|
|
58
201
|
rubocop (>= 1.7.0, < 2.0)
|
59
202
|
rubocop-ast (>= 0.4.0)
|
60
203
|
ruby-progressbar (1.11.0)
|
204
|
+
sprockets (4.0.2)
|
205
|
+
concurrent-ruby (~> 1.0)
|
206
|
+
rack (> 1, < 3)
|
207
|
+
sprockets-rails (3.4.2)
|
208
|
+
actionpack (>= 5.2)
|
209
|
+
activesupport (>= 5.2)
|
210
|
+
sprockets (>= 3.0.0)
|
211
|
+
sqlite3 (1.4.2)
|
61
212
|
standard (1.7.0)
|
62
213
|
rubocop (= 1.25.0)
|
63
214
|
rubocop-performance (= 1.13.2)
|
215
|
+
strscan (3.0.1)
|
216
|
+
thor (1.2.1)
|
217
|
+
timeout (0.2.0)
|
64
218
|
tzinfo (2.0.4)
|
65
219
|
concurrent-ruby (~> 1.0)
|
66
220
|
unicode-display_width (2.1.0)
|
221
|
+
websocket-driver (0.7.5)
|
222
|
+
websocket-extensions (>= 0.1.0)
|
223
|
+
websocket-extensions (0.1.5)
|
67
224
|
with_advisory_lock (4.6.0)
|
68
225
|
activerecord (>= 4.2)
|
226
|
+
xpath (3.2.0)
|
227
|
+
nokogiri (~> 1.8)
|
228
|
+
zeitwerk (2.5.4)
|
69
229
|
|
70
230
|
PLATFORMS
|
231
|
+
arm64-darwin-21
|
71
232
|
x86_64-darwin-19
|
233
|
+
x86_64-linux
|
72
234
|
|
73
235
|
DEPENDENCIES
|
236
|
+
capybara (>= 3.26)
|
237
|
+
debug
|
74
238
|
headmin!
|
75
239
|
minitest (~> 5.0)
|
240
|
+
minitest-spec-rails (~> 6.1)
|
241
|
+
rails (~> 7.0)
|
76
242
|
rake (~> 13.0)
|
243
|
+
sprockets-rails (~> 3.4)
|
244
|
+
sqlite3 (~> 1.4)
|
77
245
|
standard (~> 1.7)
|
78
246
|
|
79
247
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ A complete library of commonly used components to build an admin interface in yo
|
|
4
4
|
|
5
5
|
[](https://rubygems.org/gems/headmin)
|
6
6
|
[](https://www.npmjs.com/package/headmin)
|
7
|
+
[](https://github.com/frontierdotbe/headmin/actions/workflows/ci.yml)
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -88,6 +89,12 @@ When adding new dependencies, make sure you add them to the `package.json` file
|
|
88
89
|
|
89
90
|
## Testing
|
90
91
|
|
92
|
+
Run tests with
|
93
|
+
|
94
|
+
```shell
|
95
|
+
rake test
|
96
|
+
```
|
97
|
+
|
91
98
|
If you want to test a specific feature in a staging environment without releasing the gem, you can refer to the remote
|
92
99
|
repo in your Gemfile and package.json.
|
93
100
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "bundler/gem_tasks"
|
4
2
|
require "rake/testtask"
|
5
3
|
|
@@ -9,8 +7,4 @@ Rake::TestTask.new(:test) do |t|
|
|
9
7
|
t.test_files = FileList["test/**/*_test.rb"]
|
10
8
|
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
RuboCop::RakeTask.new
|
15
|
-
|
16
|
-
task default: %i[test rubocop]
|
10
|
+
task default: %i[test]
|
@@ -1,11 +1,11 @@
|
|
1
1
|
export default class {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
return window.I18n.locale
|
2
|
+
static get locale () {
|
3
|
+
if (window.I18n === undefined) {
|
4
|
+
const locale = document.querySelector('html').getAttribute('lang')
|
5
|
+
window.I18n = {
|
6
|
+
locale: locale || 'en'
|
7
|
+
}
|
10
8
|
}
|
11
|
-
|
9
|
+
return window.I18n.locale
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,255 @@
|
|
1
|
+
/* global fetch */
|
2
|
+
import { Controller } from '@hotwired/stimulus'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static get targets () {
|
6
|
+
return ['input', 'dropdown', 'dropdownItem']
|
7
|
+
}
|
8
|
+
|
9
|
+
static get values () {
|
10
|
+
return {
|
11
|
+
url: String
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
connect () {
|
16
|
+
// Focus
|
17
|
+
this.inputTarget.addEventListener('focus', (event) => {
|
18
|
+
this.show()
|
19
|
+
})
|
20
|
+
|
21
|
+
// Typing
|
22
|
+
this.inputTarget.addEventListener('keydown', (event) => {
|
23
|
+
this.handleKeydown(event)
|
24
|
+
})
|
25
|
+
|
26
|
+
// Clicked outside dropdown
|
27
|
+
document.addEventListener('click', (event) => {
|
28
|
+
this.handleOutsideClick(event)
|
29
|
+
})
|
30
|
+
}
|
31
|
+
|
32
|
+
handleKeydown (event) {
|
33
|
+
this.show()
|
34
|
+
|
35
|
+
const keyCode = parseInt(event.keyCode, 10)
|
36
|
+
if (this.isArrowKey(keyCode)) {
|
37
|
+
this.handleArrowKey(keyCode)
|
38
|
+
} else if (this.isEnterKey(keyCode)) {
|
39
|
+
this.selectActiveItem()
|
40
|
+
} else {
|
41
|
+
this.handleTextKey()
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
selectActiveItem () {
|
46
|
+
this.activeItem().click()
|
47
|
+
}
|
48
|
+
|
49
|
+
isEnterKey (keyCode) {
|
50
|
+
return keyCode === 13
|
51
|
+
}
|
52
|
+
|
53
|
+
handleArrowKey (keyCode) {
|
54
|
+
switch (keyCode) {
|
55
|
+
case 38:
|
56
|
+
this.handleArrowUp()
|
57
|
+
break
|
58
|
+
case 40:
|
59
|
+
this.handleArrowDown()
|
60
|
+
break
|
61
|
+
default:
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
handleArrowUp () {
|
66
|
+
this.selectPreviousItem()
|
67
|
+
}
|
68
|
+
|
69
|
+
handleArrowDown () {
|
70
|
+
this.selectNextItem()
|
71
|
+
}
|
72
|
+
|
73
|
+
selectNextItem () {
|
74
|
+
const next = this.nextItem()
|
75
|
+
this.deselectAll()
|
76
|
+
next.classList.add('active')
|
77
|
+
}
|
78
|
+
|
79
|
+
nextItem () {
|
80
|
+
const current = this.activeItem()
|
81
|
+
|
82
|
+
// Select first item if nothing selected
|
83
|
+
if (!this.hasSelectedItem()) {
|
84
|
+
return this.firstItem()
|
85
|
+
}
|
86
|
+
|
87
|
+
if (this.isItemLast(current)) {
|
88
|
+
return this.firstItem()
|
89
|
+
} else {
|
90
|
+
const index = this.itemIndex(current)
|
91
|
+
return this.itemAtIndex(index + 1)
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
selectPreviousItem () {
|
96
|
+
const previous = this.previousItem()
|
97
|
+
this.deselectAll()
|
98
|
+
previous.classList.add('active')
|
99
|
+
}
|
100
|
+
|
101
|
+
previousItem () {
|
102
|
+
const current = this.activeItem()
|
103
|
+
|
104
|
+
// Select last item if nothing selected
|
105
|
+
if (!this.hasSelectedItem()) {
|
106
|
+
return this.lastItem()
|
107
|
+
}
|
108
|
+
|
109
|
+
if (this.isItemFirst(current)) {
|
110
|
+
return this.lastItem()
|
111
|
+
} else {
|
112
|
+
const index = this.itemIndex(current)
|
113
|
+
return this.itemAtIndex(index - 1)
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
deselectAll () {
|
118
|
+
this.dropdownItemTargets.forEach(dropdownItem => {
|
119
|
+
dropdownItem.classList.remove('active')
|
120
|
+
})
|
121
|
+
}
|
122
|
+
|
123
|
+
itemAtIndex (index) {
|
124
|
+
return this.dropdownItemTargets[index]
|
125
|
+
}
|
126
|
+
|
127
|
+
firstItem () {
|
128
|
+
return this.itemAtIndex(0)
|
129
|
+
}
|
130
|
+
|
131
|
+
lastItem () {
|
132
|
+
return this.itemAtIndex(this.dropdownItemTargets.length - 1)
|
133
|
+
}
|
134
|
+
|
135
|
+
hasSelectedItem () {
|
136
|
+
return this.activeItem() !== undefined
|
137
|
+
}
|
138
|
+
|
139
|
+
activeItem () {
|
140
|
+
return this.dropdownItemTargets.find((item) => {
|
141
|
+
return item.classList.contains('active')
|
142
|
+
})
|
143
|
+
}
|
144
|
+
|
145
|
+
isItemLast (item) {
|
146
|
+
return this.itemIndex(item) === this.dropdownItemTargets.length - 1
|
147
|
+
}
|
148
|
+
|
149
|
+
isItemFirst (item) {
|
150
|
+
return this.itemIndex(item) === 0
|
151
|
+
}
|
152
|
+
|
153
|
+
itemIndex (item) {
|
154
|
+
return Array.from(this.dropdownItemTargets).indexOf(item)
|
155
|
+
}
|
156
|
+
|
157
|
+
handleTextKey () {
|
158
|
+
// 1. fetch info
|
159
|
+
this.fetchCollection().then((html) => {
|
160
|
+
// 2. render html
|
161
|
+
this.renderCollection(html)
|
162
|
+
}).then(() => {
|
163
|
+
// 3. sort by relevance
|
164
|
+
// ...
|
165
|
+
// 4. Highlight
|
166
|
+
this.highlight()
|
167
|
+
})
|
168
|
+
}
|
169
|
+
|
170
|
+
show () {
|
171
|
+
if (this.isDropdownEmpty()) {
|
172
|
+
this.dropdownTarget.classList.remove('d-none')
|
173
|
+
} else {
|
174
|
+
this.hide()
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
hide () {
|
179
|
+
this.dropdownTarget.classList.add('d-none')
|
180
|
+
}
|
181
|
+
|
182
|
+
isDropdownEmpty () {
|
183
|
+
return this.dropdownTarget.textContent.trim().length > 0
|
184
|
+
}
|
185
|
+
|
186
|
+
isArrowKey (keyCode) {
|
187
|
+
const arrowKeyCodes = [37, 38, 39, 40]
|
188
|
+
return arrowKeyCodes.includes(keyCode)
|
189
|
+
}
|
190
|
+
|
191
|
+
fetchCollection () {
|
192
|
+
if (this.isRemote()) {
|
193
|
+
return fetch(this.urlValue).then((response) => {
|
194
|
+
return response.text()
|
195
|
+
}).catch((error) => {
|
196
|
+
console.error('The URL you provided for the autocomplete collection didn\'t return a successful result', error)
|
197
|
+
})
|
198
|
+
} else {
|
199
|
+
return Promise.resolve(this.dropdownTarget.innerHTML)
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
renderCollection (html) {
|
204
|
+
this.dropdownTarget.innerHTML = html
|
205
|
+
}
|
206
|
+
|
207
|
+
isRemote () {
|
208
|
+
return this.hasUrlValue
|
209
|
+
}
|
210
|
+
|
211
|
+
highlight () {
|
212
|
+
const query = this.value()
|
213
|
+
this.dropdownItemTargets.forEach(dropdownItem => {
|
214
|
+
let text = dropdownItem.innerHTML
|
215
|
+
|
216
|
+
// Clean up past results
|
217
|
+
text = text.replace(/<mark.*?>(.*?)<\/mark>/ig, '$1')
|
218
|
+
|
219
|
+
// Highlight query
|
220
|
+
const regex2 = new RegExp(`(${query})`, 'gi')
|
221
|
+
text = text.replace(regex2, '<mark>$1</mark>')
|
222
|
+
|
223
|
+
dropdownItem.innerHTML = text
|
224
|
+
})
|
225
|
+
}
|
226
|
+
|
227
|
+
select (event) {
|
228
|
+
this.inputTarget.value = event.target.getAttribute('value')
|
229
|
+
this.hide()
|
230
|
+
}
|
231
|
+
|
232
|
+
value () {
|
233
|
+
return this.inputTarget.value
|
234
|
+
}
|
235
|
+
|
236
|
+
numberOfCharacters () {
|
237
|
+
return this.value().length
|
238
|
+
}
|
239
|
+
|
240
|
+
handleOutsideClick (event) {
|
241
|
+
if (!this.isClickedInside(event)) {
|
242
|
+
this.hide()
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
isClickedInside (event) {
|
247
|
+
if (!event) {
|
248
|
+
return false
|
249
|
+
}
|
250
|
+
const inInput = this.inputTarget.contains(event.target)
|
251
|
+
const inDropdown = this.dropdownTarget.contains(event.target)
|
252
|
+
|
253
|
+
return (inInput || inDropdown)
|
254
|
+
}
|
255
|
+
}
|