satis 2.1.62 → 2.1.63

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: e2140ef631e3f79034be38c47c204c5261cd8045a4da09bfa781002d2ed858a0
4
- data.tar.gz: 875613115ccdea9a294c08f6bba283316a4fb2ea4b5300a538bd20506b971b8a
3
+ metadata.gz: 6e910fd153359b41593e0a0e2b1332756c666b0a28c3596cfcf776678a710cfb
4
+ data.tar.gz: b7e71eadd1ad93c5eccdc8262b66d7d8c4e7e712dbb7c86b9c2a200df9d8024b
5
5
  SHA512:
6
- metadata.gz: b860a1fcdaa917ba2626db31bc06026fb41ef621439cc96b3ba17010f84ce8f7834370fefbd79ea1bf278d28c583db54d4cbfcabc10698da72cb253dafe28a0a
7
- data.tar.gz: 7c7aa7776086015f8aa60757473f832fe946d7a982e94c40d3f3fd635c157624c0787fc37747203c6fa2494987918f7691ed638b2efeada2f5df108d69dc5c98
6
+ metadata.gz: 40304ef3d719bffaf1713c561860b4d11f2b4cf73e417c955d6611e1aa24d1d9577d4950d0374fd03d73f966e87ce7a0880d8801b990561a96f7a25920bf4446
7
+ data.tar.gz: 7bfb0392ddf0b528ffd1fdf94d870e33b71376e6641fbf328c66207c22dae1e8e2d5ddaba14ee8a90c680df3a590cd48f1b1b2d9a5f375cc66346558afd542d1
@@ -1,7 +1,7 @@
1
1
  div.satis-date-time-picker data-controller="satis-date-time-picker" data-satis-date-time-picker-time-picker-value=time_picker.to_s data-satis-date-time-picker-clearable-value=clearable.to_s data-satis-date-time-picker-locale-value="" data-satis-date-time-picker-range-value=range.to_s data-satis-date-time-picker-multiple-value=multiple.to_s data-satis-date-time-picker-week-start-value=week_start data-satis-date-time-picker-inline-value=inline.to_s data-satis-date-time-picker-format-value=JSON.dump(format)
2
2
  .relative.flex.items-center
3
3
  = form.text_field attribute, options[:input_html].merge(class: 'hidden')
4
- input.form-control data-action="focus->satis-date-time-picker#showCalendar input->satis-date-time-picker#dateTimeEntered" data-satis-date-time-picker-target="input" type="text"
4
+ input.form-control class=input_class data-action="focus->satis-date-time-picker#showCalendar input->satis-date-time-picker#dateTimeEntered" data-satis-date-time-picker-target="input" type="text"
5
5
  .absolute.inset-y-0.right-0.flex.py-1.5.pr-1.5
6
6
  button.cursor-pointer.w-6.h-full.flex.items-center.text-gray-400.outline-none.focus:outline-none data-satis-date-time-picker-target="clearButton" data-action="click->satis-date-time-picker#clear"
7
7
  i.fas.fa-xmark
@@ -43,6 +43,10 @@ module Satis
43
43
  def week_start
44
44
  Date::DAYS_INTO_WEEK[Date.beginning_of_week] || 1
45
45
  end
46
+
47
+ def input_class
48
+ [@options.fetch(:input_html, {}).fetch(:class, ""), form.has_error?(attribute) ? "is-invalid" : ""].join(" ")
49
+ end
46
50
  end
47
51
  end
48
52
  end
@@ -20,13 +20,14 @@ export default class DropdownComponentController extends ApplicationController {
20
20
  ]
21
21
 
22
22
  static values = {
23
- chainTo: String,
24
- freeText: Boolean,
25
- needsExactMatch: Boolean,
26
- pageSize: Number,
27
- url: String,
28
- urlParams: Object,
29
- isMultiple: Boolean
23
+ chainTo: String,
24
+ freeText: Boolean,
25
+ needsExactMatch: Boolean,
26
+ pageSize: Number,
27
+ url: String,
28
+ urlParams: Object,
29
+ isMultiple: Boolean,
30
+ minSearchQueryLength: Number
30
31
  }
31
32
 
32
33
  connect() {
@@ -48,8 +49,6 @@ export default class DropdownComponentController extends ApplicationController {
48
49
  // To remember what the last search was we did
49
50
  this.searchQueryValue = null
50
51
  this.lastSearch = null
51
- this.minSearchQueryLength = 2
52
-
53
52
  // To remember what the last options were we got from the server to prevent unnecessary refreshes
54
53
  // and unexpected events
55
54
  this.lastServerRefreshOptions = new Set()
@@ -241,8 +240,8 @@ export default class DropdownComponentController extends ApplicationController {
241
240
  search(event) {
242
241
  this.searchQueryValue = this.searchInputTarget.value
243
242
 
244
- if(this.searchInputTarget.value.length === 0 && !this.isMultipleValue){
245
- if(this.nrOfItems === 1) this.lowLightSelected();
243
+ if (this.searchInputTarget.value.length === 0 && !this.isMultipleValue) {
244
+ if (this.nrOfItems === 1) this.lowLightSelected()
246
245
  this.hiddenSelectTarget.innerHTML = ""
247
246
  this.hiddenSelectTarget.add(this.createOption())
248
247
  }
@@ -279,7 +278,7 @@ export default class DropdownComponentController extends ApplicationController {
279
278
  this.lastPage = null
280
279
  this.endPage = null
281
280
 
282
- this.lowLightSelected();
281
+ this.lowLightSelected()
283
282
  this.selectedIndex = -1
284
283
 
285
284
  if (this.hasUrlValue) {
@@ -421,9 +420,9 @@ export default class DropdownComponentController extends ApplicationController {
421
420
  } else {
422
421
  this.filterResultsChainTo()
423
422
 
424
- if(this.hasResults && !this.searchQueryChanged){
423
+ if (this.hasResults && !this.searchQueryChanged) {
425
424
  this.showResultsList(event)
426
- }else {
425
+ } else {
427
426
  if (this.hasUrlValue)
428
427
  this.fetchResults(event)
429
428
  else
@@ -492,7 +491,7 @@ export default class DropdownComponentController extends ApplicationController {
492
491
 
493
492
  localResults(event) {
494
493
  if (!this.searchQueryChanged) {
495
- if(!this.resultsShown) {
494
+ if (!this.resultsShown) {
496
495
  if (this.hasResults)
497
496
  this.showResultsList(event)
498
497
  else this.showSelectedItem()
@@ -511,7 +510,7 @@ export default class DropdownComponentController extends ApplicationController {
511
510
  } else {
512
511
  previouslyVisibleItemsCount++
513
512
  }
514
- });
513
+ })
515
514
 
516
515
  this.filterResultsChainTo()
517
516
 
@@ -520,7 +519,7 @@ export default class DropdownComponentController extends ApplicationController {
520
519
  let matches = []
521
520
  this.itemTargets.forEach((item) => {
522
521
  const text = item.getAttribute("data-satis-dropdown-item-text")
523
- const matched = this.needsExactMatchValue ? searchValue.localeCompare(text, undefined, {sensitivity: 'base'}) === 0 : text.toLowerCase().includes(searchValue.toLowerCase())
522
+ const matched = this.needsExactMatchValue ? searchValue.localeCompare(text, undefined, { sensitivity: 'base' }) === 0 : text.toLowerCase().includes(searchValue.toLowerCase())
524
523
 
525
524
  const isHidden = item.classList.contains("hidden")
526
525
  if (!isHidden) {
@@ -541,9 +540,9 @@ export default class DropdownComponentController extends ApplicationController {
541
540
  }
542
541
 
543
542
  // auto select if there is only one match and we are not in freetext mode
544
- if(!this.freeTextValue) {
543
+ if (!this.freeTextValue) {
545
544
  if (matches.length === 1) {
546
- if (this.filteredSearchQuery.length >= this.minSearchQueryLength &&
545
+ if (this.filteredSearchQuery.length >= this.minSearchQueryLengthValue &&
547
546
  matches[0].getAttribute("data-satis-dropdown-item-text").toLowerCase().indexOf(this.lastSearch.toLowerCase()) >= 0) {
548
547
  const dataDiv = matches[0].closest('[data-satis-dropdown-target="item"]')
549
548
  this.selectItem(dataDiv)
@@ -553,7 +552,7 @@ export default class DropdownComponentController extends ApplicationController {
553
552
  this.showSelectedItem()
554
553
  }
555
554
  // the selected item if there was only 1 item visible before
556
- } else if(previouslyVisibleItemsCount === 1 && matches.length > 1) {
555
+ } else if (previouslyVisibleItemsCount === 1 && matches.length > 1) {
557
556
  this.setSelectedItem()
558
557
  }
559
558
  }
@@ -569,7 +568,7 @@ export default class DropdownComponentController extends ApplicationController {
569
568
  (this.currentPage == this.lastPage || this.currentPage == this.endPage)) ||
570
569
  !this.hasUrlValue
571
570
  ) {
572
- if(!this.resultsShown) {
571
+ if (!this.resultsShown) {
573
572
  if (this.hasResults)
574
573
  this.showResultsList(event)
575
574
  else this.showSelectedItem()
@@ -608,19 +607,19 @@ export default class DropdownComponentController extends ApplicationController {
608
607
  }
609
608
 
610
609
  // auto select when there is only 1 value
611
- if (this.filteredSearchQuery.length >= this.minSearchQueryLength && this.nrOfItems === 1 && !this.freeTextValue) {
610
+ if (this.filteredSearchQuery.length >= this.minSearchQueryLengthValue && this.nrOfItems === 1 && !this.freeTextValue) {
612
611
  const dataDiv = this.itemTargets[0].closest('[data-satis-dropdown-target="item"]')
613
612
  this.selectItem(dataDiv)
614
613
  this.setSelectedItem(dataDiv.getAttribute("data-satis-dropdown-item-value"))
615
614
  this.searchQueryValue = ""
616
- } else if(this.searchQueryValue?.length > 0) {
615
+ } else if (this.searchQueryValue?.length > 0) {
617
616
  // hide all items that don't match the search query
618
617
  const searchValue = this.searchQueryValue
619
618
  let matches = []
620
619
  this.itemTargets.forEach((item) => {
621
620
  const text = item.getAttribute("data-satis-dropdown-item-text")
622
621
  const matched = this.needsExactMatchValue
623
- ? searchValue.localeCompare(text, undefined, { sensitivity: "base" }) === 0 : text.toLowerCase().includes(searchValue.toLowerCase())
622
+ ? searchValue.localeCompare(text, undefined, { sensitivity: "base" }) === 0 : text?.toLowerCase().includes(searchValue.toLowerCase())
624
623
 
625
624
  const isHidden = item.classList.contains("hidden")
626
625
  if (!isHidden) {
@@ -688,8 +687,8 @@ export default class DropdownComponentController extends ApplicationController {
688
687
  return promise
689
688
  }
690
689
 
691
- get filteredSearchQuery(){
692
- if(this.searchQueryValue < this.minSearchQueryLength) return ""
690
+ get filteredSearchQuery() {
691
+ if (this.searchQueryValue < this.minSearchQueryLengthValue) return ""
693
692
  return this.searchQueryValue
694
693
  }
695
694
 
@@ -866,9 +865,9 @@ export default class DropdownComponentController extends ApplicationController {
866
865
  this.selectedIndex = -1
867
866
  return
868
867
  }
869
- const itemTargets = this.itemTargets;
870
- const visibleItems = itemTargets.filter(item => !item.classList.contains("hidden"));
871
- this.selectedIndex = visibleItems.findIndex(item => item.getAttribute("data-satis-dropdown-item-value") === value);
868
+ const itemTargets = this.itemTargets
869
+ const visibleItems = itemTargets.filter(item => !item.classList.contains("hidden"))
870
+ this.selectedIndex = visibleItems.findIndex(item => item.getAttribute("data-satis-dropdown-item-value") === value)
872
871
  this.highLightSelected()
873
872
  }
874
873
 
@@ -884,9 +883,9 @@ export default class DropdownComponentController extends ApplicationController {
884
883
  this.highLightSelected()
885
884
  }
886
885
  validateSearchQuery() {
887
- const trimmedValue = this.searchInputTarget.value.trim();
888
- const elements = this.selectedItemsTemplateTarget.content.querySelectorAll(`[data-satis-dropdown-item-text*="${trimmedValue}"]`);
889
- const selected = Array.from(elements).find(element => element.getAttribute('data-satis-dropdown-item-text').trim() === trimmedValue);
886
+ const trimmedValue = this.searchInputTarget.value.trim()
887
+ const elements = this.selectedItemsTemplateTarget.content.querySelectorAll(`[data-satis-dropdown-item-text*="${trimmedValue}"]`)
888
+ const selected = Array.from(elements).find(element => element.getAttribute('data-satis-dropdown-item-text').trim() === trimmedValue)
890
889
  if (!selected && this.searchInputTarget.value.length > 0 && !this.freeTextValue) {
891
890
  this.searchInputTarget.closest(".sts-dropdown").classList.toggle("warning", true)
892
891
  } else {
@@ -955,13 +954,13 @@ export default class DropdownComponentController extends ApplicationController {
955
954
  }
956
955
 
957
956
  get hasFocus() {
958
- const activeElement = document.activeElement;
957
+ const activeElement = document.activeElement
959
958
  if (activeElement === this.element ||
960
959
  this.element.contains(activeElement) ||
961
960
  this.element.querySelector(':focus') !== null) {
962
- return true;
961
+ return true
963
962
  }
964
- return false;
963
+ return false
965
964
  }
966
965
 
967
966
  // Selected items are being cached in selectItemsTemplate. Sometimes we want to show the selected item in the results list
@@ -971,7 +970,7 @@ export default class DropdownComponentController extends ApplicationController {
971
970
  || this.freeTextValue
972
971
  || this.hiddenSelectTarget.options.length === 0
973
972
  || !this.hasFocus
974
- ) return false;
973
+ ) return false
975
974
 
976
975
  const option = this.hiddenSelectTarget.options[0]
977
976
  let item = this.itemsTarget.querySelector(`[data-satis-dropdown-item-value="${option.value}"]`)
@@ -988,12 +987,12 @@ export default class DropdownComponentController extends ApplicationController {
988
987
  }
989
988
  }
990
989
 
991
- if(item) {
990
+ if (item) {
992
991
  if (!this.resultsShown)
993
992
  this.showResultsList()
994
993
  this.setSelectedItem(option.value)
995
994
  }
996
995
 
997
- return item != null;
996
+ return item != null
998
997
  }
999
998
  }
data/lib/satis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Satis
2
- VERSION = "2.1.62"
2
+ VERSION = "2.1.63"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.62
4
+ version: 2.1.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser