bullet_train 1.19.2 → 1.21.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/app/javascript/index.js +3 -1
- data/app/views/account/invitations/show.html.erb +3 -3
- data/app/views/account/memberships/_tombstones.html.erb +1 -1
- data/app/views/account/memberships/edit.html.erb +1 -1
- data/app/views/account/memberships/show.html.erb +4 -4
- data/app/views/account/onboarding/invitation_lists/new.html.erb +1 -1
- data/app/views/account/onboarding/user_details/edit.html.erb +1 -1
- data/app/views/account/onboarding/user_email/edit.html.erb +1 -1
- data/app/views/account/teams/_form.html.erb +1 -1
- data/app/views/account/teams/new.html.erb +2 -2
- data/app/views/devise/registrations/_two_factor.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +1 -1
- data/docs/billing/stripe.md +1 -1
- data/docs/field-partials/options.md +1 -0
- data/docs/field-partials.md +22 -21
- data/docs/trademark.md +1 -1
- data/docs/upgrades.md +1 -1
- data/lib/bullet_train/resolver.rb +2 -2
- data/lib/bullet_train/version.rb +1 -1
- data/lib/tasks/bullet_train_tasks.rake +3 -1
- metadata +3 -4
- data/app/javascript/support/turn.js +0 -183
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e96df89a7d40b6e275f57575a3157fc6ee8bccfae6b9c2a14d0b872c894bf5e3
|
4
|
+
data.tar.gz: f727d6df61d995e6e4d8b9e0a8f7143fd3881ab95b8baaa321f6e75ade40c9dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf9f4bc490dae9ed4e1d05a6ea89d3e161c87862856229a13a87ec61c721480c6da32af4101143307bd748be22833a6956c8bac981210946feaf31eeb0937de
|
7
|
+
data.tar.gz: 914984adb93662453c4d0fd6f1c2c58624f3fbc4bef6e2560a9451ba8f153fe28386877443fe838b5cf02bfdd8f4c8f9e971e8122ccde6e59db7efb55f8f9fb8
|
data/app/javascript/index.js
CHANGED
@@ -13,17 +13,17 @@
|
|
13
13
|
|
14
14
|
<div class="space-y-3 pb-1">
|
15
15
|
<p><%= raw t('.accept_the_invitation', user_email: current_user.email) %></p>
|
16
|
-
<%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid),
|
16
|
+
<%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), data: { turbo_method: :post }, class: 'button full' %>
|
17
17
|
</div>
|
18
18
|
|
19
19
|
<%= render 'account/shared/decision_line' %>
|
20
20
|
|
21
21
|
<div class="space-y-3">
|
22
22
|
<p><%= t('.sign_out') %></p>
|
23
|
-
<%= link_to t('.buttons.logout'), main_app.destroy_user_session_path,
|
23
|
+
<%= link_to t('.buttons.logout'), main_app.destroy_user_session_path, data: { turbo_method: 'delete' }, class: 'button-alternative full' %>
|
24
24
|
</div>
|
25
25
|
<% else %>
|
26
|
-
<%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid),
|
26
|
+
<%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), data: { turbo_method: :post }, class: 'button full' %>
|
27
27
|
<% end %>
|
28
28
|
</div>
|
29
29
|
<% end %>
|
@@ -47,7 +47,7 @@
|
|
47
47
|
<% end %>
|
48
48
|
</td>
|
49
49
|
<td class="text-right">
|
50
|
-
<%= link_to t('.buttons.reinvite'), [:reinvite, :account, membership], class: 'button-secondary button-smaller',
|
50
|
+
<%= link_to t('.buttons.reinvite'), [:reinvite, :account, membership], class: 'button-secondary button-smaller', data: { turbo_method: :post, turbo_confirm: t('.buttons.confirmations.reinvite', membership_name: membership.name)} if can? :edit, membership %>
|
51
51
|
<%= link_to t('.buttons.show'), [:account, membership], class: 'button-secondary button-smaller' %>
|
52
52
|
</td>
|
53
53
|
</tr>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% if can? :destroy, @membership %>
|
10
10
|
<%= render 'account/shared/box', divider: true do |box| %>
|
11
11
|
<% box.t title: '.remove_header', description: '.remove_description' %>
|
12
|
-
<% box.body.button_to t('.buttons.destroy'), [:account, @membership],
|
12
|
+
<% box.body.button_to t('.buttons.destroy'), [:account, @membership], data: { turbo_method: :delete, turbo_confirm: t('.buttons.confirmations.destroy') }, class: 'button' %>
|
13
13
|
<% end %>
|
14
14
|
<% end %>
|
15
15
|
<% end %>
|
@@ -34,19 +34,19 @@
|
|
34
34
|
|
35
35
|
<% box.actions do %>
|
36
36
|
<% if @membership.tombstone? %>
|
37
|
-
<%= link_to t('.buttons.reinvite'), [:reinvite, :account, @membership], class: first_button_primary,
|
37
|
+
<%= link_to t('.buttons.reinvite'), [:reinvite, :account, @membership], class: first_button_primary, data: {turbo_method: :post, turbo_confirm: t('.buttons.confirmations.reinvite', membership_name: @membership.name)} if can? :edit, @membership %>
|
38
38
|
<% end %>
|
39
39
|
|
40
40
|
<%= link_to t('.buttons.edit'), [:edit, :account, @membership], class: first_button_primary if can? :edit, @membership %>
|
41
41
|
|
42
42
|
<% unless @membership.tombstone? %>
|
43
43
|
<% if @membership.admin? %>
|
44
|
-
<%= link_to t('.buttons.demote'), [:demote, :account, @membership],
|
44
|
+
<%= link_to t('.buttons.demote'), [:demote, :account, @membership], data: { turbo_method: :post, turbo_confirm: t('global.confirm_message') }, class: first_button_primary if can? :demote, @membership %>
|
45
45
|
<% else %>
|
46
|
-
<%= link_to t('.buttons.promote'), [:promote, :account, @membership],
|
46
|
+
<%= link_to t('.buttons.promote'), [:promote, :account, @membership], data: { turbo_method: :post, turbo_confirm: t('global.confirm_message') }, class: first_button_primary if can? :promote, @membership %>
|
47
47
|
<% end %>
|
48
48
|
<% if (can? :destroy, @membership) && (!@membership.platform_agent) %>
|
49
|
-
<%= button_to t(".buttons.#{membership_destroy_locale_key(@membership)}"), [:account, @membership], method: :delete, data: {
|
49
|
+
<%= button_to t(".buttons.#{membership_destroy_locale_key(@membership)}"), [:account, @membership], method: :delete, data: { turbo_confirm: t(".buttons.confirmations.#{membership_destroy_locale_key(@membership)}", model_locales(@membership)) }, class: first_button_primary %>
|
50
50
|
<% end %>
|
51
51
|
<% end %>
|
52
52
|
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<% if other_teams.any? %>
|
23
23
|
<%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
|
24
24
|
<% else %>
|
25
|
-
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary,
|
25
|
+
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, data: {turbo_method: 'delete'} %>
|
26
26
|
<% end %>
|
27
27
|
</div>
|
28
28
|
<% end %>
|
@@ -39,7 +39,7 @@
|
|
39
39
|
<% if other_teams.any? %>
|
40
40
|
<%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
|
41
41
|
<% else %>
|
42
|
-
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary,
|
42
|
+
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, data: {turbo_method: 'delete'} %>
|
43
43
|
<% end %>
|
44
44
|
</div>
|
45
45
|
<% end %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<% if current_user.teams.any? %>
|
25
25
|
<%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
|
26
26
|
<% else %>
|
27
|
-
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary,
|
27
|
+
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, data:{turbo_method: 'delete'} %>
|
28
28
|
<% end %>
|
29
29
|
</div>
|
30
30
|
<% end %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<div class="buttons">
|
19
19
|
<%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
|
20
20
|
<% if controller.action_name == "edit" %>
|
21
|
-
<%= link_to t('account.teams.buttons.destroy'), [:account, team],
|
21
|
+
<%= link_to t('account.teams.buttons.destroy'), [:account, team], data: { turbo_method: :delete, turbo_confirm: t('account.teams.buttons.confirmations.destroy') } %>
|
22
22
|
<% end %>
|
23
23
|
<%= link_to t('global.buttons.cancel'), form.object.persisted? ? [:account, team] : [:account, :teams], class: "button-secondary" %>
|
24
24
|
</div>
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
<p><%= t('.log_out') %></p>
|
34
34
|
</div>
|
35
35
|
|
36
|
-
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: 'button-alternative full',
|
36
|
+
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: 'button-alternative full', dat:{turbo_method: 'delete'} %></p>
|
37
37
|
|
38
38
|
<%= render 'account/shared/decision_line' %>
|
39
39
|
|
@@ -70,7 +70,7 @@ end
|
|
70
70
|
<% if current_user.teams.any? %>
|
71
71
|
<%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
|
72
72
|
<% else %>
|
73
|
-
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary,
|
73
|
+
<%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, data:{turbo_method: 'delete'} %>
|
74
74
|
<% end %>
|
75
75
|
</div>
|
76
76
|
<% end %>
|
@@ -52,9 +52,9 @@
|
|
52
52
|
<% end %>
|
53
53
|
|
54
54
|
<% if current_user.otp_required_for_login? %>
|
55
|
-
<%= link_to t('users.edit.two_factor.buttons.disable'), account_two_factor_path,
|
55
|
+
<%= link_to t('users.edit.two_factor.buttons.disable'), account_two_factor_path, data:{turbo_method: :delete}, remote: true, class: "button" %>
|
56
56
|
<% else %>
|
57
|
-
<%= link_to t('users.edit.two_factor.buttons.enable'), account_two_factor_path,
|
57
|
+
<%= link_to t('users.edit.two_factor.buttons.enable'), account_two_factor_path, data:{turbo_method: :post}, remote: true, class: "button" %>
|
58
58
|
<% end %>
|
59
59
|
</div>
|
60
60
|
<% end %>
|
@@ -38,6 +38,6 @@
|
|
38
38
|
|
39
39
|
<h3><%= t('devise.headers.cancel_account') %></h3>
|
40
40
|
|
41
|
-
<p>Unhappy? <%= button_to t('devise.buttons.cancel_account'), registration_path(resource_name), data: {
|
41
|
+
<p>Unhappy? <%= button_to t('devise.buttons.cancel_account'), registration_path(resource_name), data: { turbo_confirm: t('global.confirm_message') }, method: :delete %></p>
|
42
42
|
|
43
43
|
<%= link_to t('global.buttons.back'), :back %>
|
data/docs/billing/stripe.md
CHANGED
@@ -290,4 +290,4 @@ As mentioned earlier, all of the links we provided for configuration steps on St
|
|
290
290
|
|
291
291
|
## 10. You should be done!
|
292
292
|
|
293
|
-
[Let us know on Discord](
|
293
|
+
[Let us know on Discord](https://discord.gg/gmfybM8kA6) if any part of this guide was not clear or could be improved!
|
@@ -52,3 +52,4 @@ Most of the field partials have a native Rails form helper working underneath. P
|
|
52
52
|
| `text_field` | [text_field](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-text_field) |
|
53
53
|
| `number_field` | [number_field](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-number_field) |
|
54
54
|
| `trix_editor` | [rich_text_editor](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-rich_text_area) |
|
55
|
+
| `code_editor` | [text_area](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-text_area) |
|
data/docs/field-partials.md
CHANGED
@@ -142,27 +142,28 @@ Certain form field partials like `buttons` and `super_select` can also have thei
|
|
142
142
|
|
143
143
|
## Available Field Partials
|
144
144
|
|
145
|
-
| Field Partial | Data Type | Multiple Values? | Assignment Helpers | JavaScript Library | Description
|
146
|
-
|
147
|
-
| [`address_field`](/docs/field-partials/address-field.md) | `Address` | | | | Adds a block of address fields. On change, its country super-select auto-updates the state/province/region super-select and postal/zip code field label.
|
148
|
-
| `boolean` | `boolean` | | `assign_boolean` | |
|
149
|
-
| [`buttons`](/docs/field-partials/buttons.md) | `string` | Optionally | `assign_checkboxes` | |
|
150
|
-
| `checkbox` | `boolean` | | `assign_boolean` | |
|
151
|
-
| `image` | `string` or `attachment`* | | | |
|
152
|
-
| `color_picker` | `string` | | | [pickr](https://simonwep.github.io/pickr/) |
|
153
|
-
| `date_and_time_field` | `datetime` | | | [Date Range Picker](https://www.daterangepicker.com) |
|
154
|
-
| `date_field` | `date` | | | [Date Range Picker](https://www.daterangepicker.com) |
|
155
|
-
| `email_field` | `string` | | | |
|
156
|
-
| `emoji_field` | `string` | | | [Emoji Mart](https://missiveapp.com/open/emoji-mart) | A front-end library which allows users to browse and select emojis with ease. |
|
157
|
-
| [`file_field`](/docs/field-partials/file-field.md) | `attachment` | | | [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) |
|
158
|
-
| `options` | `string` | Optionally | `assign_checkboxes` | |
|
159
|
-
| `password_field` | `string` | | | |
|
160
|
-
| `phone_field` | `string` | | | [International Telephone Input](https://intl-tel-input.com) | Ensures telephone numbers are in a format that can be used by providers like Twilio.
|
161
|
-
| [`super_select`](/docs/field-partials/super-select.md) | `string` | Optionally | `assign_select_options` | [Select2](https://select2.org) | Provides powerful option search, AJAX search, and multi-select functionality.
|
162
|
-
| `text_area` | `text` | | | |
|
163
|
-
| `text_field` | `string` | | | |
|
164
|
-
| `number_field` | `integer` | | | |
|
165
|
-
| `trix_editor` | `text` | | | [Trix](https://github.com/basecamp/trix) | Basic HTML-powered formatting features and support for at-mentions amongst team members.
|
145
|
+
| Field Partial | Data Type | Multiple Values? | Assignment Helpers | JavaScript Library | Description |
|
146
|
+
|----------------------------------------------------------|---------------------------|------------------|-------------------------|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
147
|
+
| [`address_field`](/docs/field-partials/address-field.md) | `Address` | | | | Adds a block of address fields. On change, its country super-select auto-updates the state/province/region super-select and postal/zip code field label. |
|
148
|
+
| `boolean` | `boolean` | | `assign_boolean` | | |
|
149
|
+
| [`buttons`](/docs/field-partials/buttons.md) | `string` | Optionally | `assign_checkboxes` | | |
|
150
|
+
| `checkbox` | `boolean` | | `assign_boolean` | | |
|
151
|
+
| `image` | `string` or `attachment`* | | | | |
|
152
|
+
| `color_picker` | `string` | | | [pickr](https://simonwep.github.io/pickr/) | |
|
153
|
+
| `date_and_time_field` | `datetime` | | | [Date Range Picker](https://www.daterangepicker.com) | |
|
154
|
+
| `date_field` | `date` | | | [Date Range Picker](https://www.daterangepicker.com) | |
|
155
|
+
| `email_field` | `string` | | | | |
|
156
|
+
| `emoji_field` | `string` | | | [Emoji Mart](https://missiveapp.com/open/emoji-mart) | A front-end library which allows users to browse and select emojis with ease. | |
|
157
|
+
| [`file_field`](/docs/field-partials/file-field.md) | `attachment` | | | [Active Storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) | |
|
158
|
+
| `options` | `string` | Optionally | `assign_checkboxes` | | |
|
159
|
+
| `password_field` | `string` | | | | |
|
160
|
+
| `phone_field` | `string` | | | [International Telephone Input](https://intl-tel-input.com) | Ensures telephone numbers are in a format that can be used by providers like Twilio. |
|
161
|
+
| [`super_select`](/docs/field-partials/super-select.md) | `string` | Optionally | `assign_select_options` | [Select2](https://select2.org) | Provides powerful option search, AJAX search, and multi-select functionality. |
|
162
|
+
| `text_area` | `text` | | | | |
|
163
|
+
| `text_field` | `string` | | | | |
|
164
|
+
| `number_field` | `integer` | | | | |
|
165
|
+
| `trix_editor` | `text` | | | [Trix](https://github.com/basecamp/trix) | Basic HTML-powered formatting features and support for at-mentions amongst team members. |
|
166
|
+
| `code_editor` | `text` | | | [Monaco](https://microsoft.github.io/monaco-editor/) | A powerful code editor supporting multiple coding languages (see [languages available by default](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)). |
|
166
167
|
|
167
168
|
* The data type for `image` fields will vary based on whether you're using Cloudinary or ActiveStorage.
|
168
169
|
For Cloudinary you should use `string`, and for ActiveStorage you should use `attachment`.
|
data/docs/trademark.md
CHANGED
@@ -22,4 +22,4 @@ Here are some examples that would require explicit permission:
|
|
22
22
|
- "Bullet Train Conference"
|
23
23
|
- "Bullet Train Podcast"
|
24
24
|
|
25
|
-
If you've got an idea and aren't sure about the name, message Andrew Culver privately [on Discord](https://discord.gg/
|
25
|
+
If you've got an idea and aren't sure about the name, message Andrew Culver privately [on Discord](https://discord.gg/gmfybM8kA6) or [via Twitter DM](https://twitter.com/andrewculver). If you know anything about trademarks, you know we're required to enforce our policies, so thank you for understanding! 🙏
|
data/docs/upgrades.md
CHANGED
@@ -120,7 +120,7 @@ git merge v1.4.1
|
|
120
120
|
It's quite possible you'll get some merge conflicts at this point. No big deal! Just go through and
|
121
121
|
resolve them like you would if you were integrating code from another developer on your team. We tend
|
122
122
|
to comment our code heavily, but if you have any questions about the code you're trying to understand,
|
123
|
-
let us know on [Discord!](https://discord.gg/
|
123
|
+
let us know on [Discord!](https://discord.gg/gmfybM8kA6)
|
124
124
|
|
125
125
|
One of the files that's likely to have conflicts, and which can be the most frustrating to resolve is
|
126
126
|
`Gemfile.lock`. You can try to sort it out by hand, or you can checkout a clean copy and then let bundler
|
@@ -53,7 +53,7 @@ module BulletTrain
|
|
53
53
|
else
|
54
54
|
`mkdir -p #{source_file[:project_path].split("/")[0...-1].join("/")}`
|
55
55
|
puts "Ejecting `#{source_file[:absolute_path]}` to `#{source_file[:project_path]}`".green
|
56
|
-
File.open(
|
56
|
+
File.open(source_file[:project_path].to_s, "w+") do |file|
|
57
57
|
case source_file[:project_path].split(".").last
|
58
58
|
when "rb", "yml"
|
59
59
|
file.puts "# Ejected from `#{source_file[:relative_path] || source_file[:package_name]}`.\n\n"
|
@@ -95,7 +95,7 @@ module BulletTrain
|
|
95
95
|
end
|
96
96
|
|
97
97
|
if open
|
98
|
-
path = source_file[:package_name] ? source_file[:absolute_path] :
|
98
|
+
path = source_file[:package_name] ? source_file[:absolute_path] : source_file[:project_path].to_s
|
99
99
|
puts "Opening `#{path}`.\n".green
|
100
100
|
|
101
101
|
# TODO: Use TerminalCommands to open this file
|
data/lib/bullet_train/version.rb
CHANGED
@@ -231,7 +231,9 @@ namespace :bullet_train do
|
|
231
231
|
puts "Run `bin/hack --watch-js` to see which other npm packages you can watch.".blue
|
232
232
|
puts "When you're done, you can hit <Control + C> and we'll clean all off this up.".blue
|
233
233
|
puts ""
|
234
|
-
|
234
|
+
# TODO: On this next line we're disabling standard for now. We should circle back and remove the comment
|
235
|
+
# that disables standard and then try the recommendation that it makes. And test it to make sure it works.
|
236
|
+
bt_package = framework_packages.select { |k, v| k == :bullet_train } # standard:disable Style/HashSlice
|
235
237
|
set_npm_package("--watch-js", bt_package)
|
236
238
|
|
237
239
|
puts ""
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: standard
|
@@ -437,7 +437,6 @@ files:
|
|
437
437
|
- app/javascript/controllers/text_toggle_controller.js
|
438
438
|
- app/javascript/electron/index.js
|
439
439
|
- app/javascript/index.js
|
440
|
-
- app/javascript/support/turn.js
|
441
440
|
- app/mailers/concerns/mailers/base.rb
|
442
441
|
- app/mailers/devise_mailer.rb
|
443
442
|
- app/mailers/user_mailer.rb
|
@@ -678,7 +677,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
678
677
|
- !ruby/object:Gem::Version
|
679
678
|
version: '0'
|
680
679
|
requirements: []
|
681
|
-
rubygems_version: 3.6.
|
680
|
+
rubygems_version: 3.6.7
|
682
681
|
specification_version: 4
|
683
682
|
summary: Bullet Train
|
684
683
|
test_files: []
|
@@ -1,183 +0,0 @@
|
|
1
|
-
// MIT License
|
2
|
-
//
|
3
|
-
// Copyright (c) 2021 Dom Christie
|
4
|
-
//
|
5
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
// of this software and associated documentation files (the "Software"), to deal
|
7
|
-
// in the Software without restriction, including without limitation the rights
|
8
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
// copies of the Software, and to permit persons to whom the Software is
|
10
|
-
// furnished to do so, subject to the following conditions:
|
11
|
-
//
|
12
|
-
// The above copyright notice and this permission notice shall be included in all
|
13
|
-
// copies or substantial portions of the Software.
|
14
|
-
//
|
15
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
// SOFTWARE.
|
22
|
-
|
23
|
-
class Turn {
|
24
|
-
constructor (action) {
|
25
|
-
this.action = action
|
26
|
-
this.beforeExitClasses = new Set()
|
27
|
-
this.exitClasses = new Set()
|
28
|
-
this.enterClasses = new Set()
|
29
|
-
}
|
30
|
-
|
31
|
-
exit () {
|
32
|
-
this.animateOut = animationsEnd('[data-turn-exit]')
|
33
|
-
this.addClasses('before-exit')
|
34
|
-
requestAnimationFrame(() => {
|
35
|
-
this.addClasses('exit')
|
36
|
-
this.removeClasses('before-exit')
|
37
|
-
})
|
38
|
-
}
|
39
|
-
|
40
|
-
async beforeEnter (event) {
|
41
|
-
if (this.action === 'restore') return
|
42
|
-
|
43
|
-
event.preventDefault()
|
44
|
-
|
45
|
-
if (this.isPreview) {
|
46
|
-
this.hasPreview = true
|
47
|
-
await this.animateOut
|
48
|
-
} else {
|
49
|
-
await this.animateOut
|
50
|
-
if (this.animateIn) await this.animateIn
|
51
|
-
}
|
52
|
-
|
53
|
-
event.detail.resume()
|
54
|
-
}
|
55
|
-
|
56
|
-
async enter () {
|
57
|
-
this.removeClasses('exit')
|
58
|
-
|
59
|
-
if (this.shouldAnimateEnter) {
|
60
|
-
this.animateIn = animationsEnd('[data-turn-enter]')
|
61
|
-
this.addClasses('enter')
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
async complete () {
|
66
|
-
await this.animateIn
|
67
|
-
this.removeClasses('enter')
|
68
|
-
}
|
69
|
-
|
70
|
-
abort () {
|
71
|
-
this.removeClasses('before-exit')
|
72
|
-
this.removeClasses('exit')
|
73
|
-
this.removeClasses('enter')
|
74
|
-
}
|
75
|
-
|
76
|
-
get shouldAnimateEnter () {
|
77
|
-
if (this.action === 'restore') return false
|
78
|
-
if (this.isPreview) return true
|
79
|
-
if (this.hasPreview) return false
|
80
|
-
return true
|
81
|
-
}
|
82
|
-
|
83
|
-
get isPreview () {
|
84
|
-
return document.documentElement.hasAttribute('data-turbo-preview')
|
85
|
-
}
|
86
|
-
|
87
|
-
addClasses (type) {
|
88
|
-
document.documentElement.classList.add(`turn-${type}`)
|
89
|
-
|
90
|
-
Array.from(document.querySelectorAll(`[data-turn-${type}]`)).forEach((element) => {
|
91
|
-
element.dataset[`turn${pascalCase(type)}`].split(/\s+/).forEach((klass) => {
|
92
|
-
if (klass) {
|
93
|
-
element.classList.add(klass)
|
94
|
-
this[`${camelCase(type)}Classes`].add(klass)
|
95
|
-
}
|
96
|
-
})
|
97
|
-
})
|
98
|
-
}
|
99
|
-
|
100
|
-
removeClasses (type) {
|
101
|
-
document.documentElement.classList.remove(`turn-${type}`)
|
102
|
-
|
103
|
-
Array.from(document.querySelectorAll(`[data-turn-${type}]`)).forEach((element) => {
|
104
|
-
this[`${camelCase(type)}Classes`].forEach((klass) => element.classList.remove(klass))
|
105
|
-
})
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
Turn.start = function () {
|
110
|
-
if (motionSafe()) {
|
111
|
-
for (var event in this.eventListeners) {
|
112
|
-
addEventListener(event, this.eventListeners[event])
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
Turn.stop = function () {
|
118
|
-
for (var event in this.eventListeners) {
|
119
|
-
removeEventListener(event, this.eventListeners[event])
|
120
|
-
}
|
121
|
-
delete this.currentTurn
|
122
|
-
}
|
123
|
-
|
124
|
-
Turn.eventListeners = {
|
125
|
-
'turbo:visit': function (event) {
|
126
|
-
if (this.currentTurn) this.currentTurn.abort()
|
127
|
-
this.currentTurn = new this(event.detail.action)
|
128
|
-
this.currentTurn.exit()
|
129
|
-
}.bind(Turn),
|
130
|
-
'turbo:before-render': function (event) {
|
131
|
-
this.currentTurn.beforeEnter(event)
|
132
|
-
}.bind(Turn),
|
133
|
-
'turbo:render': function () {
|
134
|
-
this.currentTurn.enter()
|
135
|
-
}.bind(Turn),
|
136
|
-
'turbo:load': function () {
|
137
|
-
if (this.currentTurn) this.currentTurn.complete()
|
138
|
-
}.bind(Turn),
|
139
|
-
'popstate': function () {
|
140
|
-
if (this.currentTurn && this.currentTurn.action !== 'restore') {
|
141
|
-
this.currentTurn.abort()
|
142
|
-
}
|
143
|
-
}.bind(Turn)
|
144
|
-
}
|
145
|
-
|
146
|
-
function prefersReducedMotion () {
|
147
|
-
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)')
|
148
|
-
return !mediaQuery || mediaQuery.matches
|
149
|
-
}
|
150
|
-
|
151
|
-
function motionSafe () {
|
152
|
-
return !prefersReducedMotion()
|
153
|
-
}
|
154
|
-
|
155
|
-
function animationsEnd (selector) {
|
156
|
-
const elements = [...document.querySelectorAll(selector)]
|
157
|
-
|
158
|
-
return Promise.all(elements.map((element) => {
|
159
|
-
return new Promise((resolve) => {
|
160
|
-
function listener () {
|
161
|
-
element.removeEventListener('animationend', listener)
|
162
|
-
resolve()
|
163
|
-
}
|
164
|
-
element.addEventListener('animationend', listener)
|
165
|
-
})
|
166
|
-
}))
|
167
|
-
}
|
168
|
-
|
169
|
-
function pascalCase (string) {
|
170
|
-
return string.split(/[^\w]/).map(capitalize).join('')
|
171
|
-
}
|
172
|
-
|
173
|
-
function camelCase (string) {
|
174
|
-
return string.split(/[^\w]/).map(
|
175
|
-
(w, i) => i === 0 ? w.toLowerCase() : capitalize(w)
|
176
|
-
).join('')
|
177
|
-
}
|
178
|
-
|
179
|
-
function capitalize (string) {
|
180
|
-
return string.replace(/^\w/, (c) => c.toUpperCase())
|
181
|
-
}
|
182
|
-
|
183
|
-
Turn.start()
|