shadcn-ui 0.0.14 → 0.0.15

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: a39d85928cde2116a4a0ffb5bf8790b0697474a1dff54e164a8817f3e1c02dc7
4
- data.tar.gz: d79e0cd3ce519b91f2e4186ed7946c67bf50e3d9125a0ad3767f6326ef21662b
3
+ metadata.gz: 93c6ce85664d4fc60c3ada95d4754c69238619e07bdf0fb63843b03c84c7a7b0
4
+ data.tar.gz: 2e160df29b1166826c587d2ada208fff89095f4d1a5b22b7bbd76fc287ba737b
5
5
  SHA512:
6
- metadata.gz: d0cb9bf3bb84df2d8a57c334fc43db494ab29a3b31d31ec5192aee725a3e321a207a56b86df94abc1d8b010c0728f1e718002edb6da371c0467cd4a63651ebdd
7
- data.tar.gz: 11839c8a282b0497e8a2a33726818b7889bfd0299a60d41b6887f24f3b81b8189f2171e9dfb8e0749cf660b5b2e2a36ba502c6996c8491b90067459f8e18b59b
6
+ metadata.gz: 18709282a252039a411e0106b46cf31b02eedca5deb4841f747d880919adffcdd1eca3a262c85289f8bd5bdf8cdb88b3804690f3352a087f470279a8b797c8b8
7
+ data.tar.gz: a2aed1d08e07b2485b4773a0ce4860b62f9e8e96584d465c001a568b136348085bb7017b3e46a540df002de30728965cfbb0f0d00380d9f7d6859dbc15d374b8
@@ -1,8 +1,8 @@
1
1
  // Imported from: https://github.com/airblade/stimulus-datepicker/blob/main/src/datepicker.js
2
2
 
3
3
  import { Controller } from "@hotwired/stimulus";
4
- import IsoDate from "../../utils/iso_date";
5
- import { useClickOutside } from "https://ga.jspm.io/npm:stimulus-use@0.52.2/dist/index.js";
4
+ import IsoDate from "utils/iso_date";
5
+ import { useClickOutside } from "stimulus-use";
6
6
 
7
7
  // All dates are local, not UTC.
8
8
  export default class UIDatePickerController extends Controller {
@@ -1,129 +1,130 @@
1
- import { Controller } from "@hotwired/stimulus"
2
- import { useClickOutside } from "https://ga.jspm.io/npm:stimulus-use@0.51.3/dist/index.js";
3
- import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from "../../utils/bodyScrollLock.js"
1
+ import { Controller } from "@hotwired/stimulus";
2
+ import { useClickOutside } from "stimulus-use";
3
+ import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from "utils/bodyScrollLock";
4
4
 
5
5
  export default class UISelectController extends Controller {
6
- static targets = ["value", "menu", "wrapper"]
7
- static values = { value: String }
6
+ static targets = ["value", "menu", "wrapper"];
7
+ static values = { value: String };
8
8
 
9
9
  connect() {
10
10
  useClickOutside(this);
11
- this.valueTarget.textContent = this.valueValue || this.valueTarget.textContent || "Select an option"
12
- this.selectedOption = null
11
+ this.valueTarget.textContent =
12
+ this.valueValue || this.valueTarget.textContent || "Select an option";
13
+ this.selectedOption = null;
13
14
  }
14
15
 
15
16
  disconnect() {
16
- clearAllBodyScrollLocks()
17
+ clearAllBodyScrollLocks();
17
18
  }
18
19
 
19
20
  clickOutside(event) {
20
- this.menuTarget.classList.add("hidden")
21
+ this.menuTarget.classList.add("hidden");
21
22
  }
22
23
 
23
24
  toggle() {
24
- this.menuTarget.classList.toggle("hidden")
25
- this.wrapperTarget.querySelector("button").focus()
25
+ this.menuTarget.classList.toggle("hidden");
26
+ this.wrapperTarget.querySelector("button").focus();
26
27
 
27
- const optionList = this.menuTarget.children
28
- const currentValue = this.valueTarget.textContent
29
- let childElement = null
28
+ const optionList = this.menuTarget.children;
29
+ const currentValue = this.valueTarget.textContent;
30
+ let childElement = null;
30
31
 
31
32
  if (!this.menuTarget.classList.contains("hidden")) {
32
- this.adjustScrollPosition()
33
- disableBodyScroll(this.menuTarget)
33
+ this.adjustScrollPosition();
34
+ disableBodyScroll(this.menuTarget);
34
35
  } else {
35
- enableBodyScroll(this.menuTarget)
36
+ enableBodyScroll(this.menuTarget);
36
37
  }
37
38
 
38
- Array.from(optionList).forEach(function(child){
39
- if(currentValue == child.textContent) {
40
- child.classList.add("bg-gray-200", "text-gray-900")
41
- childElement = child
39
+ Array.from(optionList).forEach(function (child) {
40
+ if (currentValue == child.textContent) {
41
+ child.classList.add("bg-gray-200", "text-gray-900");
42
+ childElement = child;
42
43
  }
43
- })
44
+ });
44
45
 
45
- if(childElement) {
46
- this.selectedOption = childElement
47
- childElement.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'start' })
46
+ if (childElement) {
47
+ this.selectedOption = childElement;
48
+ childElement.scrollIntoView({ behavior: "instant", block: "nearest", inline: "start" });
48
49
  }
49
50
  }
50
51
 
51
52
  adjustScrollPosition() {
52
- const menuHeight = this.menuTarget.offsetHeight
53
- const optionsHeight = this.menuTarget.scrollHeight
53
+ const menuHeight = this.menuTarget.offsetHeight;
54
+ const optionsHeight = this.menuTarget.scrollHeight;
54
55
  if (optionsHeight > menuHeight) {
55
- this.menuTarget.style.maxHeight = `${menuHeight}px`
56
- this.menuTarget.style.overflowY = "scroll"
56
+ this.menuTarget.style.maxHeight = `${menuHeight}px`;
57
+ this.menuTarget.style.overflowY = "scroll";
57
58
  } else {
58
- this.menuTarget.style.maxHeight = "auto"
59
- this.menuTarget.style.overflowY = "auto"
59
+ this.menuTarget.style.maxHeight = "auto";
60
+ this.menuTarget.style.overflowY = "auto";
60
61
  }
61
62
  }
62
63
 
63
64
  select(event) {
64
- const option = event.target
65
- this.setSelectedOption(option)
66
- this.selectCurrentOption()
65
+ const option = event.target;
66
+ this.setSelectedOption(option);
67
+ this.selectCurrentOption();
67
68
  }
68
69
 
69
70
  setValue(value) {
70
- this.valueValue = value
71
- this.valueTarget.textContent = value
71
+ this.valueValue = value;
72
+ this.valueTarget.textContent = value;
72
73
  }
73
74
 
74
75
  key(event) {
75
- if(this.menuTarget.classList.contains("hidden")) return
76
+ if (this.menuTarget.classList.contains("hidden")) return;
76
77
 
77
78
  switch (event.key) {
78
79
  case "Escape":
79
- this.menuTarget.classList.add("hidden")
80
- break
80
+ this.menuTarget.classList.add("hidden");
81
+ break;
81
82
  case "ArrowUp":
82
- this.selectPreviousOption(event)
83
- break
83
+ this.selectPreviousOption(event);
84
+ break;
84
85
  case "ArrowDown":
85
- this.selectNextOption(event)
86
- break
86
+ this.selectNextOption(event);
87
+ break;
87
88
  case "Enter":
88
- this.selectCurrentOption()
89
- break
89
+ this.selectCurrentOption();
90
+ break;
90
91
  }
91
92
  }
92
93
 
93
94
  selectPreviousOption(event) {
94
- const selected = this.selectedOption //this.options.querySelector(".selected")
95
- const prevOption = selected ? selected.previousElementSibling : this.options.lastElementChild
96
- this.setSelectedOption(prevOption)
95
+ const selected = this.selectedOption; //this.options.querySelector(".selected")
96
+ const prevOption = selected ? selected.previousElementSibling : this.options.lastElementChild;
97
+ this.setSelectedOption(prevOption);
97
98
  }
98
99
 
99
100
  selectNextOption(event) {
100
- const selected = this.selectedOption //this.options.querySelector(".selected")
101
- const nextOption = selected ? selected.nextElementSibling : this.options.firstElementChild
102
- this.setSelectedOption(nextOption)
101
+ const selected = this.selectedOption; //this.options.querySelector(".selected")
102
+ const nextOption = selected ? selected.nextElementSibling : this.options.firstElementChild;
103
+ this.setSelectedOption(nextOption);
103
104
  }
104
105
 
105
106
  selectCurrentOption() {
106
- const selected = this.selectedOption
107
+ const selected = this.selectedOption;
107
108
  if (selected) {
108
- this.valueTarget.textContent = selected.textContent
109
- this.menuTarget.classList.add("hidden")
109
+ this.valueTarget.textContent = selected.textContent;
110
+ this.menuTarget.classList.add("hidden");
110
111
 
111
- this.wrapperTarget.textContent = selected.getAttribute('value')
112
- this.wrapperTarget.dispatchEvent(new Event('change'))
112
+ this.wrapperTarget.textContent = selected.getAttribute("value");
113
+ this.wrapperTarget.dispatchEvent(new Event("change"));
113
114
  }
114
115
  }
115
116
 
116
117
  setSelectedOption(option) {
117
- if(!option) return
118
+ if (!option) return;
118
119
 
119
120
  // Reset the previously selected option
120
121
  if (this.selectedOption) {
121
- this.selectedOption.classList.remove("bg-gray-200", "text-gray-900")
122
+ this.selectedOption.classList.remove("bg-gray-200", "text-gray-900");
122
123
  }
123
124
 
124
125
  // Set the new selected option
125
- option.classList.add("bg-gray-200", "text-gray-900")
126
- this.selectedOption = option
127
- option.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'start' })
126
+ option.classList.add("bg-gray-200", "text-gray-900");
127
+ this.selectedOption = option;
128
+ option.scrollIntoView({ behavior: "instant", block: "nearest", inline: "start" });
128
129
  }
129
130
  }
data/config/importmap.rb CHANGED
@@ -4,10 +4,13 @@ pin "application", preload: true
4
4
  pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
5
5
  pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:@hotwired/stimulus@3.2.1/dist/stimulus.js"
6
6
  pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
7
+
7
8
  pin_all_from "app/javascript/controllers", under: "controllers"
9
+ pin_all_from "app/javascript/utils", under: "utils"
10
+
8
11
  pin "@kanety/stimulus-static-actions", to: "https://ga.jspm.io/npm:@kanety/stimulus-static-actions@1.0.1/dist/index.modern.js", preload: true
9
12
  pin "highlight.js", to: "https://ga.jspm.io/npm:highlight.js@11.8.0/es/index.js", preload: true
10
- pin "stimulus-use", to: "https://ga.jspm.io/npm:stimulus-use@0.51.3/dist/index.js", preload: true
13
+ pin "stimulus-use", to: "https://ga.jspm.io/npm:stimulus-use@0.52.2/dist/index.js", preload: true
11
14
  pin "stimulus-dropdown", to: "https://ga.jspm.io/npm:stimulus-dropdown@2.1.0/dist/stimulus-dropdown.mjs", preload: true
12
15
  pin "hotkeys-js", to: "https://ga.jspm.io/npm:hotkeys-js@3.10.4/dist/hotkeys.esm.js", preload: true
13
16
  pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.8/lib/index.js", preload: true
@@ -1,3 +1,3 @@
1
1
  module ShadcnUi
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadcn-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Flombaum