@stimulus-library/mixins 1.0.0-alpha.3 → 1.0.0-alpha.7
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/dist/index.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export * from './use_localstorage';
|
|
|
13
13
|
export * from './use_mutation_observer';
|
|
14
14
|
export * from './use_resize_observer';
|
|
15
15
|
export * from './use_temporary_content';
|
|
16
|
+
export * from './use_text_selection';
|
|
16
17
|
export * from './use_timeout';
|
|
17
18
|
export * from './use_trix_modifiers';
|
package/dist/index.js
CHANGED
|
@@ -13,5 +13,6 @@ export * from './use_localstorage';
|
|
|
13
13
|
export * from './use_mutation_observer';
|
|
14
14
|
export * from './use_resize_observer';
|
|
15
15
|
export * from './use_temporary_content';
|
|
16
|
+
export * from './use_text_selection';
|
|
16
17
|
export * from './use_timeout';
|
|
17
18
|
export * from './use_trix_modifiers';
|
|
@@ -26,7 +26,6 @@ export function useDirtyFormTracking(controller, form) {
|
|
|
26
26
|
restores.push(functions.restore);
|
|
27
27
|
});
|
|
28
28
|
useEventListener(controller, form, 'input-dirtied', () => {
|
|
29
|
-
console.log("input-dirtied");
|
|
30
29
|
form.setAttribute('data-dirty', 'true');
|
|
31
30
|
form.dispatchEvent(new CustomEvent('form-dirtied', {
|
|
32
31
|
bubbles: true,
|
|
@@ -37,7 +36,6 @@ export function useDirtyFormTracking(controller, form) {
|
|
|
37
36
|
}));
|
|
38
37
|
});
|
|
39
38
|
useEventListener(controller, form, 'input-cleaned', () => {
|
|
40
|
-
console.log("input-cleaned");
|
|
41
39
|
if (form.querySelectorAll('[data-dirty="true"]').length === 0) {
|
|
42
40
|
form.removeAttribute('data-dirty');
|
|
43
41
|
form.dispatchEvent(new CustomEvent('form-cleaned', {
|
|
@@ -74,7 +72,6 @@ function getElementLoadValue(element) {
|
|
|
74
72
|
let options = Array.from(element.options);
|
|
75
73
|
options.forEach((option) => {
|
|
76
74
|
if (option.defaultSelected) {
|
|
77
|
-
element.value = option.value;
|
|
78
75
|
return option.value;
|
|
79
76
|
}
|
|
80
77
|
});
|
|
@@ -94,7 +91,6 @@ function checkDirty(element) {
|
|
|
94
91
|
if (isElementDirty(element)) {
|
|
95
92
|
element.setAttribute('data-dirty', "true");
|
|
96
93
|
element.form?.setAttribute('data-dirty', "true");
|
|
97
|
-
console.log("input-dirtied event");
|
|
98
94
|
element.dispatchEvent(new CustomEvent('input-dirtied', {
|
|
99
95
|
bubbles: true,
|
|
100
96
|
cancelable: true,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEventListener } from "./use_event_listener";
|
|
2
|
+
export function useTextSelection(controller, handler) {
|
|
3
|
+
handler = handler.bind(controller);
|
|
4
|
+
let onSelectionChange = () => {
|
|
5
|
+
let selection = window.getSelection();
|
|
6
|
+
handler(selection);
|
|
7
|
+
};
|
|
8
|
+
let { teardown: unwatch } = useEventListener(controller, window.document, 'selectionchange', onSelectionChange);
|
|
9
|
+
let teardown = () => {
|
|
10
|
+
unwatch();
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
teardown,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"ruby on rails",
|
|
10
10
|
"ruby-on-rails"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-alpha.
|
|
12
|
+
"version": "1.0.0-alpha.7",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Sub-Xaero",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"typescript": "^5.1.3",
|
|
56
56
|
"vite": "^4.1.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "0f37528aabf5fe7acc4dee070d0bf760bacc4dc1"
|
|
59
59
|
}
|