ultimate_turbo_modal 2.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5fdea054587cce77438cee439587f3ce28ca49a2b6626d1c1bacd5acf4cf5bb
4
- data.tar.gz: 1662f021dae0bdc0a9ff9a2cc2c2a2fd29577bedddf51829249b8b3b61d35c31
3
+ metadata.gz: eb5a2d990486959d808b557642c17ada12d887416c4158d42550e9655dbe6b2f
4
+ data.tar.gz: dc3ee5b170cd735bc87a0a67a693a9a68c36c8b9cc9bde371a2a7bca0c512744
5
5
  SHA512:
6
- metadata.gz: 76a068194d26f01d2940945237b6acb97abaa7621fbdb50ea4665b5f7cf85ddc2c6fd03f1b1486ec6f3f2d7fbb0463b6540ad5fe1865b455e407a33a83499331
7
- data.tar.gz: e76696e1d26cb19a62bb71c41ecba7e5d0193e86b7a4c055e0094944108cbbdb75aea4c26c9648a464985e8b8698e7e3595f74525f1ebe4e220e9659b334cec3
6
+ metadata.gz: 5474e9849437b9e97496ba1af522d449c7c3dc26cda3e296c603acc3356f53c1ef24527cb96ecbd42e9713553940d1dd54890297fb9fa2d98f62763b39b1424e
7
+ data.tar.gz: af196848be428193650a240b3ad78512b175cf294f76821fb279546630ecbcb0d0bb3029e97d538382bc1c7c8c7005a3d03ed3354487321a0890132edf729c7e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## [2.0.0] - 2025-04-11
1
+ ## [2.0.2] - 2025-04-11
2
+
3
+ - Warn if the NPM package and Ruby Gem versions don't match.
4
+
5
+ ## [2.0.1] - 2025-04-11
2
6
 
3
7
  - Properly call `raw` for Phlex 2, and `unsafe_raw` for Phlex 1. Thanks @cavenk!
4
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ultimate_turbo_modal (2.0.1)
4
+ ultimate_turbo_modal (2.0.2)
5
5
  phlex-rails
6
6
  rails
7
7
  stimulus-rails
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -1,6 +1,9 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
  import { enter, leave } from 'el-transition';
3
3
 
4
+ // This placeholder will be replaced by rollup
5
+ const PACKAGE_VERSION = '__PACKAGE_VERSION__';
6
+
4
7
  export default class extends Controller {
5
8
  static targets = ["container", "content"]
6
9
  static values = {
@@ -10,6 +13,9 @@ export default class extends Controller {
10
13
 
11
14
  connect() {
12
15
  let _this = this;
16
+
17
+ this.#checkVersions();
18
+
13
19
  this.showModal();
14
20
 
15
21
  this.turboFrame = this.element.closest('turbo-frame');
@@ -105,4 +111,19 @@ export default class extends Controller {
105
111
  #resetHistoryAdvanced() {
106
112
  document.body.removeAttribute("data-turbo-modal-history-advanced");
107
113
  }
114
+
115
+ #checkVersions() {
116
+ const gemVersion = this.element.dataset.utmrVersion;
117
+
118
+ if (!gemVersion) {
119
+ // If the attribute isn't set (e.g., in production), skip the check.
120
+ return;
121
+ }
122
+
123
+ if (gemVersion !== PACKAGE_VERSION) {
124
+ console.warn(
125
+ `[UltimateTurboModal] Version Mismatch!\n\nGem Version: ${gemVersion}\nJS Version: ${PACKAGE_VERSION}\n\nPlease ensure both the 'ultimate_turbo_modal' gem and the 'ultimate-turbo-modal' npm package are updated to the same version.\nElement:`, this.element
126
+ );
127
+ }
128
+ }
108
129
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ultimate_turbo_modal",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ultimate_turbo_modal",
9
- "version": "2.0.0",
9
+ "version": "2.0.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@hotwired/stimulus": "^3.2.2",
@@ -19,6 +19,7 @@
19
19
  "rollup": "^2.79.1",
20
20
  "rollup-plugin-copy": "^3.5.0",
21
21
  "rollup-plugin-css-only": "^4.3.0",
22
+ "rollup-plugin-replace": "^2.2.0",
22
23
  "rollup-plugin-terser": "^7.0.2"
23
24
  }
24
25
  },
@@ -700,6 +701,16 @@
700
701
  "graceful-fs": "^4.1.6"
701
702
  }
702
703
  },
704
+ "node_modules/magic-string": {
705
+ "version": "0.25.9",
706
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
707
+ "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
708
+ "dev": true,
709
+ "license": "MIT",
710
+ "dependencies": {
711
+ "sourcemap-codec": "^1.4.8"
712
+ }
713
+ },
703
714
  "node_modules/merge-stream": {
704
715
  "version": "2.0.0",
705
716
  "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -926,6 +937,18 @@
926
937
  "rollup": "<5"
927
938
  }
928
939
  },
940
+ "node_modules/rollup-plugin-replace": {
941
+ "version": "2.2.0",
942
+ "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz",
943
+ "integrity": "sha512-/5bxtUPkDHyBJAKketb4NfaeZjL5yLZdeUihSfbF2PQMz+rSTEb8ARKoOl3UBT4m7/X+QOXJo3sLTcq+yMMYTA==",
944
+ "deprecated": "This module has moved and is now available at @rollup/plugin-replace. Please update your dependencies. This version is no longer maintained.",
945
+ "dev": true,
946
+ "license": "MIT",
947
+ "dependencies": {
948
+ "magic-string": "^0.25.2",
949
+ "rollup-pluginutils": "^2.6.0"
950
+ }
951
+ },
929
952
  "node_modules/rollup-plugin-terser": {
930
953
  "version": "7.0.2",
931
954
  "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
@@ -942,6 +965,23 @@
942
965
  "rollup": "^2.0.0"
943
966
  }
944
967
  },
968
+ "node_modules/rollup-pluginutils": {
969
+ "version": "2.8.2",
970
+ "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
971
+ "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==",
972
+ "dev": true,
973
+ "license": "MIT",
974
+ "dependencies": {
975
+ "estree-walker": "^0.6.1"
976
+ }
977
+ },
978
+ "node_modules/rollup-pluginutils/node_modules/estree-walker": {
979
+ "version": "0.6.1",
980
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
981
+ "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
982
+ "dev": true,
983
+ "license": "MIT"
984
+ },
945
985
  "node_modules/run-parallel": {
946
986
  "version": "1.2.0",
947
987
  "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@@ -1028,6 +1068,14 @@
1028
1068
  "source-map": "^0.6.0"
1029
1069
  }
1030
1070
  },
1071
+ "node_modules/sourcemap-codec": {
1072
+ "version": "1.4.8",
1073
+ "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
1074
+ "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
1075
+ "deprecated": "Please use @jridgewell/sourcemap-codec instead",
1076
+ "dev": true,
1077
+ "license": "MIT"
1078
+ },
1031
1079
  "node_modules/supports-color": {
1032
1080
  "version": "7.2.0",
1033
1081
  "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate_turbo_modal",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "The ultimate Turbo / Stimulus / Hotwire modal window for Rails",
5
5
  "main": "dist/ultimate_turbo_modal.min.js",
6
6
  "module": "dist/ultimate_turbo_modal.min.js",
@@ -39,6 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@rollup/plugin-node-resolve": "^15.2.3",
42
+ "@rollup/plugin-replace": "^6.0.2",
42
43
  "rollup": "^2.79.1",
43
44
  "rollup-plugin-copy": "^3.5.0",
44
45
  "rollup-plugin-css-only": "^4.3.0",
@@ -1,6 +1,11 @@
1
1
  import resolve from '@rollup/plugin-node-resolve';
2
2
  import css from 'rollup-plugin-css-only';
3
3
  import { terser } from 'rollup-plugin-terser';
4
+ import replace from '@rollup/plugin-replace';
5
+ import { readFileSync } from 'fs';
6
+
7
+ const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
8
+ const packageVersion = pkg.version;
4
9
 
5
10
  export default {
6
11
  input: './index.js',
@@ -19,6 +24,12 @@ export default {
19
24
  inlineDynamicImports: true,
20
25
  plugins: [
21
26
  resolve(),
22
- css({ output: 'vanilla.css' })
27
+ css({ output: 'vanilla.css' }),
28
+ replace({
29
+ preventAssignment: true,
30
+ values: {
31
+ '__PACKAGE_VERSION__': JSON.stringify(packageVersion)
32
+ }
33
+ })
23
34
  ]
24
35
  };
data/javascript/yarn.lock CHANGED
@@ -61,7 +61,7 @@
61
61
  "@jridgewell/gen-mapping" "^0.3.5"
62
62
  "@jridgewell/trace-mapping" "^0.3.25"
63
63
 
64
- "@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14":
64
+ "@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.5.0":
65
65
  version "1.5.0"
66
66
  resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz"
67
67
  integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==
@@ -111,6 +111,14 @@
111
111
  is-module "^1.0.0"
112
112
  resolve "^1.22.1"
113
113
 
114
+ "@rollup/plugin-replace@^6.0.2":
115
+ version "6.0.2"
116
+ resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-6.0.2.tgz#2f565d312d681e4570ff376c55c5c08eb6f1908d"
117
+ integrity sha512-7QaYCf8bqF04dOy7w/eHmJeNExxTYwvKAmlSAH/EaWWUzbT0h5sbF6bktFoX/0F/0qwng5/dWFMyf3gzaM8DsQ==
118
+ dependencies:
119
+ "@rollup/pluginutils" "^5.0.1"
120
+ magic-string "^0.30.3"
121
+
114
122
  "@rollup/pluginutils@5", "@rollup/pluginutils@^5.0.1":
115
123
  version "5.1.4"
116
124
  resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz"
@@ -406,6 +414,13 @@ jsonfile@^4.0.0:
406
414
  optionalDependencies:
407
415
  graceful-fs "^4.1.6"
408
416
 
417
+ magic-string@^0.30.3:
418
+ version "0.30.17"
419
+ resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.17.tgz#450a449673d2460e5bbcfba9a61916a1714c7453"
420
+ integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==
421
+ dependencies:
422
+ "@jridgewell/sourcemap-codec" "^1.5.0"
423
+
409
424
  merge-stream@^2.0.0:
410
425
  version "2.0.0"
411
426
  resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"
@@ -138,32 +138,38 @@ class UltimateTurboModal::Base < Phlex::HTML
138
138
  end
139
139
 
140
140
  def div_dialog(&block)
141
+ data_attributes = {
142
+ controller: "modal",
143
+ modal_target: "container",
144
+ modal_advance_url_value: advance_url,
145
+ modal_allowed_click_outside_selector_value: allowed_click_outside_selector,
146
+ action: "turbo:submit-end->modal#submitEnd keyup@window->modal#closeWithKeyboard click@window->modal#outsideModalClicked click->modal#outsideModalClicked",
147
+ transition_enter: "ease-out duration-100",
148
+ transition_enter_start: "opacity-0",
149
+ transition_enter_end: "opacity-100",
150
+ transition_leave: "ease-in duration-50",
151
+ transition_leave_start: "opacity-100",
152
+ transition_leave_end: "opacity-0",
153
+ padding: padding?.to_s,
154
+ title: title?.to_s,
155
+ header: header?.to_s,
156
+ close_button: close_button?.to_s,
157
+ header_divider: header_divider?.to_s,
158
+ footer_divider: footer_divider?.to_s
159
+ }
160
+
161
+ if defined?(Rails) && (Rails.env.development? || Rails.env.test?)
162
+ data_attributes[:utmr_version] = UltimateTurboModal::VERSION
163
+ end
164
+
141
165
  div(id: "modal-container",
142
166
  class: self.class::DIV_DIALOG_CLASSES,
143
167
  role: "dialog",
144
168
  aria: {
145
- labeled_by: "modal-title-h",
146
- modal: true
169
+ modal: true,
170
+ labelledby: "modal-title-h"
147
171
  },
148
- data: {
149
- controller: "modal",
150
- modal_target: "container",
151
- modal_advance_url_value: advance_url,
152
- modal_allowed_click_outside_selector_value: allowed_click_outside_selector,
153
- action: "turbo:submit-end->modal#submitEnd keyup@window->modal#closeWithKeyboard click@window->modal#outsideModalClicked click->modal#outsideModalClicked",
154
- transition_enter: "ease-out duration-100",
155
- transition_enter_start: "opacity-0",
156
- transition_enter_end: "opacity-100",
157
- transition_leave: "ease-in duration-50",
158
- transition_leave_start: "opacity-100",
159
- transition_leave_end: "opacity-0",
160
- padding: padding?.to_s,
161
- title: title?.to_s,
162
- header: header?.to_s,
163
- close_button: close_button?.to_s,
164
- header_divider: header_divider?.to_s,
165
- footer_divider: footer_divider?.to_s
166
- }, &block)
172
+ data: data_attributes, &block)
167
173
  end
168
174
 
169
175
  def div_overlay
@@ -22,6 +22,15 @@ fi
22
22
  if [ "$1" != "--skip-gem" ]; then
23
23
  echo "Building and releasing gem..."
24
24
  bundle exec rake build
25
+
26
+ # Check if Gemfile.lock is git dirty
27
+ if ! git diff --quiet Gemfile.lock; then
28
+ echo "Gemfile.lock is dirty. Adding, committing, and pushing."
29
+ git add Gemfile.lock
30
+ git commit -m "Update Gemfile.lock"
31
+ bundle exec rake build
32
+ fi
33
+
25
34
  bundle exec rake release
26
35
  else
27
36
  echo "Skipping gem build and release..."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate_turbo_modal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Mercier