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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c6ce85664d4fc60c3ada95d4754c69238619e07bdf0fb63843b03c84c7a7b0
|
4
|
+
data.tar.gz: 2e160df29b1166826c587d2ada208fff89095f4d1a5b22b7bbd76fc287ba737b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 "
|
5
|
-
import { useClickOutside } from "
|
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 "
|
3
|
-
import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from "
|
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 =
|
12
|
-
|
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:
|
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(
|
112
|
-
this.wrapperTarget.dispatchEvent(new Event(
|
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:
|
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.
|
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
|
data/lib/shadcn-ui/version.rb
CHANGED