@radioactive-labs/plutonium 0.35.1 → 0.37.0
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.
- package/package.json +1 -1
- package/src/css/slim_select.css +78 -21
- package/src/dist/css/plutonium.css +11 -1
- package/src/dist/js/plutonium.js +1188 -1552
- package/src/dist/js/plutonium.js.map +4 -4
- package/src/dist/js/plutonium.min.js +70 -70
- package/src/dist/js/plutonium.min.js.map +4 -4
- package/src/js/controllers/register_controllers.js +2 -0
- package/src/js/controllers/textarea_autogrow_controller.js +56 -0
|
@@ -22,6 +22,7 @@ import RemoteModalController from "./remote_modal_controller.js"
|
|
|
22
22
|
import KeyValueStoreController from "./key_value_store_controller.js"
|
|
23
23
|
import BulkActionsController from "./bulk_actions_controller.js"
|
|
24
24
|
import FilterPanelController from "./filter_panel_controller.js"
|
|
25
|
+
import TextareaAutogrowController from "./textarea_autogrow_controller.js"
|
|
25
26
|
|
|
26
27
|
export default function (application) {
|
|
27
28
|
// Register controllers here
|
|
@@ -48,4 +49,5 @@ export default function (application) {
|
|
|
48
49
|
application.register("key-value-store", KeyValueStoreController)
|
|
49
50
|
application.register("bulk-actions", BulkActionsController)
|
|
50
51
|
application.register("filter-panel", FilterPanelController)
|
|
52
|
+
application.register("textarea-autogrow", TextareaAutogrowController)
|
|
51
53
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
export default class extends Controller {
|
|
4
|
+
static values = {
|
|
5
|
+
maxHeight: { type: Number, default: 0 } // 0 means use CSS max-height or 50vh
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
connect() {
|
|
9
|
+
this.resize()
|
|
10
|
+
this.element.addEventListener("input", this.resize)
|
|
11
|
+
window.addEventListener("resize", this.resize)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
disconnect() {
|
|
15
|
+
this.element.removeEventListener("input", this.resize)
|
|
16
|
+
window.removeEventListener("resize", this.resize)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
resize = () => {
|
|
20
|
+
const element = this.element
|
|
21
|
+
const maxHeight = this.#getMaxHeight()
|
|
22
|
+
|
|
23
|
+
// Reset to auto to get the natural scroll height
|
|
24
|
+
element.style.height = "auto"
|
|
25
|
+
element.style.overflow = "hidden"
|
|
26
|
+
|
|
27
|
+
const scrollHeight = element.scrollHeight
|
|
28
|
+
|
|
29
|
+
if (maxHeight > 0 && scrollHeight > maxHeight) {
|
|
30
|
+
element.style.height = `${maxHeight}px`
|
|
31
|
+
element.style.overflow = "auto"
|
|
32
|
+
} else {
|
|
33
|
+
element.style.height = `${scrollHeight}px`
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#getMaxHeight() {
|
|
38
|
+
if (this.maxHeightValue > 0) {
|
|
39
|
+
return this.maxHeightValue
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Check for CSS max-height
|
|
43
|
+
const computedStyle = window.getComputedStyle(this.element)
|
|
44
|
+
const cssMaxHeight = computedStyle.maxHeight
|
|
45
|
+
|
|
46
|
+
if (cssMaxHeight && cssMaxHeight !== "none") {
|
|
47
|
+
const parsed = parseFloat(cssMaxHeight)
|
|
48
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
49
|
+
return parsed
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Default to 300px
|
|
54
|
+
return 300
|
|
55
|
+
}
|
|
56
|
+
}
|