polaris_view_components 3.1.1 → 3.1.3

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: 1d930e9979e26f2a16e58a86aaf5477360eb518602900671407fbad50476058a
4
- data.tar.gz: c65e3755b6d86787d6a6582c646ed8e81c17fbb33e6ba95fb6e975f240411840
3
+ metadata.gz: c8125de405dc965d5dc682a8c4d21c682d5a4fd2771bcbd9751fd85f429daf0f
4
+ data.tar.gz: 400fbb96829bf6bdea7cc842e60f965877a278b806cb27468b8735a30540480e
5
5
  SHA512:
6
- metadata.gz: 4b74b88c543352ce30e6db7b6478b61aeba71a7688f578335bab15464aa041e1f806f0200fadbfc8015586c18b99f543d1a8633d250e46eed03f984b3543889e
7
- data.tar.gz: 04f4ad64a553706075a8fe6a7632707e4334f3a805f717f8dfb40c1e4b47c6db314a05b9684cc923f4dfd2359aafd10b61c53ec0bc47a11b1ee683a6fc54ae24
6
+ metadata.gz: e745e7869c91205b85352e2db653b11a044c10c6e5d3c7d7c2bb759c93bd96b67eed3e148fb7df090a07f948e36ac9d4a1b588c01839bcbdac1106d12adc3c34
7
+ data.tar.gz: 2bd1f707013a22583841cf4bd5851b3bbecc5722e93132ec5449a1fb5b369ac447a3f4e82f8db42c952621c5bac93f1f96068f91de180b33dbac9901d8eb950b
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2021 Dan Gamble
1
+ Copyright 2021 Dan Gamble, Kirill Platonov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -44,10 +44,10 @@ Check out [UPGRADING.md](UPGRADING.md) for upgrade instructions.
44
44
  To get started:
45
45
 
46
46
  1. Run: `bundle install`
47
- 1. Run: `yarn install`
47
+ 1. Run: `pnpm install`
48
48
  1. Run: `bin/dev`
49
49
 
50
- It will open demo app with component previews on `localhost:4000`. You can change components and they will be updated on page reload. Component previews located in `demo/test/components/previews`.
50
+ It will open the demo app with component previews on `localhost:4000`. You can change components and they will be updated on page reload. Component previews are located in `demo/app/previews`.
51
51
 
52
52
  To run tests:
53
53
 
@@ -57,7 +57,9 @@ rake
57
57
 
58
58
  ## Releases
59
59
 
60
- The library follows [semantic versioning](https://semver.org/). To draft a new release you need to run `bin/release` with a new version number:
60
+ The library follows [semantic versioning](https://semver.org/). See [GitHub Releases](https://github.com/baoagency/polaris_view_components/releases) for release notes.
61
+
62
+ To draft a new release you need to run `bin/release` with a new version number:
61
63
 
62
64
  ```bash
63
65
  bin/release VERSION
@@ -68,7 +70,7 @@ Where the VERSION is the version number you want to release. This script will up
68
70
  To release a new version of npm package update the package.json file with the new version number and run:
69
71
 
70
72
  ```bash
71
- npm run release
73
+ pnpm release
72
74
  ```
73
75
 
74
76
  After that make sure to commit changes in package.json.
@@ -6,6 +6,8 @@ export default class extends Controller {
6
6
  static targets = ['popover', 'input', 'hiddenInput', 'results', 'option', 'emptyState']
7
7
  static values = { multiple: Boolean, url: String, selected: Array }
8
8
 
9
+ latestRequestId = 0
10
+
9
11
  connect() {
10
12
  this.inputTarget.addEventListener("input", this.onInputChange)
11
13
  }
@@ -84,6 +86,7 @@ export default class extends Controller {
84
86
  this.checkSelected()
85
87
  } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
86
88
  this.showEmptyState()
89
+ this.popoverController.show()
87
90
  } else {
88
91
  this.popoverController.forceHide()
89
92
  }
@@ -108,11 +111,16 @@ export default class extends Controller {
108
111
  }
109
112
 
110
113
  async fetchResults() {
114
+ const query = this.value
115
+ const requestId = ++this.latestRequestId
111
116
  const response = await get(this.urlValue, {
112
- query: { q: this.value }
117
+ query: { q: query }
113
118
  })
114
119
  if (response.ok) {
115
120
  const results = await response.html
121
+
122
+ if (requestId !== this.latestRequestId || query !== this.value) return
123
+
116
124
  this.resultsTarget.innerHTML = results
117
125
  this.handleResults()
118
126
  }
@@ -180,6 +180,7 @@ class Autocomplete extends Controller {
180
180
  url: String,
181
181
  selected: Array
182
182
  };
183
+ latestRequestId=0;
183
184
  connect() {
184
185
  this.inputTarget.addEventListener("input", this.onInputChange);
185
186
  }
@@ -243,6 +244,7 @@ class Autocomplete extends Controller {
243
244
  this.checkSelected();
244
245
  } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
245
246
  this.showEmptyState();
247
+ this.popoverController.show();
246
248
  } else {
247
249
  this.popoverController.forceHide();
248
250
  }
@@ -265,13 +267,16 @@ class Autocomplete extends Controller {
265
267
  this.handleResults();
266
268
  }
267
269
  async fetchResults() {
270
+ const query = this.value;
271
+ const requestId = ++this.latestRequestId;
268
272
  const response = await get(this.urlValue, {
269
273
  query: {
270
- q: this.value
274
+ q: query
271
275
  }
272
276
  });
273
277
  if (response.ok) {
274
278
  const results = await response.html;
279
+ if (requestId !== this.latestRequestId || query !== this.value) return;
275
280
  this.resultsTarget.innerHTML = results;
276
281
  this.handleResults();
277
282
  }
@@ -58,7 +58,7 @@ module Polaris
58
58
  def polaris_select(method, **options, &block)
59
59
  apply_error_options(options, method)
60
60
 
61
- value = object&.public_send(method)
61
+ value = object.public_send(method) if object.respond_to?(method)
62
62
  if value.present?
63
63
  options[:selected] = value
64
64
  end
@@ -86,7 +86,7 @@ module Polaris
86
86
  def polaris_collection_check_boxes(method, collection, value_method, text_method, **options, &block)
87
87
  apply_error_options(options, method)
88
88
 
89
- value = object&.public_send(method)
89
+ value = object.public_send(method) if object.respond_to?(method)
90
90
  if value.present?
91
91
  options[:selected] = value.map { |el| el.public_send(value_method) }
92
92
  end
@@ -42,11 +42,11 @@ else
42
42
 
43
43
  unless package_json.include?("@rails/request.js")
44
44
  say "Add @rails/request.js dependency"
45
- run "yarn add @rails/request.js"
45
+ run "pnpm add @rails/request.js"
46
46
  end
47
47
 
48
48
  say "Add polaris-view-components package"
49
- run "yarn add polaris-view-components"
49
+ run "pnpm add polaris-view-components"
50
50
  end
51
51
 
52
52
  if STIMULUS_PATH.exist?
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
2
  module ViewComponents
3
- VERSION = "3.1.1"
3
+ VERSION = "3.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polaris_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gamble
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 3.0.0
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 4.2.0
36
+ version: '5.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 3.0.0
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 4.2.0
46
+ version: '5.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webdrivers
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,7 @@ dependencies:
144
144
  version: '0'
145
145
  email:
146
146
  - dan@dangamble.co.uk
147
+ - mail@kirillplatonov.com
147
148
  executables: []
148
149
  extensions: []
149
150
  extra_rdoc_files: []