@stimulus-library/utilities 0.9.11
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/arrays.d.ts +1 -0
- package/dist/arrays.js +3 -0
- package/dist/baseController.d.ts +11 -0
- package/dist/baseController.js +59 -0
- package/dist/base_controller.d.ts +11 -0
- package/dist/base_controller.js +59 -0
- package/dist/debounce.d.ts +1 -0
- package/dist/debounce.js +19 -0
- package/dist/easingFunctions.d.ts +34 -0
- package/dist/easingFunctions.js +143 -0
- package/dist/elements.d.ts +48 -0
- package/dist/elements.js +102 -0
- package/dist/ephemeralController.d.ts +5 -0
- package/dist/ephemeralController.js +40 -0
- package/dist/ephemeral_controller.d.ts +5 -0
- package/dist/ephemeral_controller.js +40 -0
- package/dist/eventBus.d.ts +3 -0
- package/dist/eventBus.js +2 -0
- package/dist/event_bus.d.ts +1 -0
- package/dist/event_bus.js +2 -0
- package/dist/events.d.ts +2 -0
- package/dist/events.js +10 -0
- package/dist/fetchRetry.d.ts +1 -0
- package/dist/fetchRetry.js +11 -0
- package/dist/getSet.d.ts +3 -0
- package/dist/getSet.js +223 -0
- package/dist/get_set.d.ts +3 -0
- package/dist/get_set.js +223 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/logging.d.ts +5 -0
- package/dist/logging.js +90 -0
- package/dist/numbers.d.ts +1 -0
- package/dist/numbers.js +3 -0
- package/dist/reactive.d.ts +1 -0
- package/dist/reactive.js +23 -0
- package/dist/requestSubmit.d.ts +2 -0
- package/dist/requestSubmit.js +20 -0
- package/dist/request_submit.d.ts +2 -0
- package/dist/request_submit.js +20 -0
- package/dist/scroll.d.ts +10 -0
- package/dist/scroll.js +51 -0
- package/dist/stimulus.d.ts +2 -0
- package/dist/stimulus.js +13 -0
- package/dist/strings.d.ts +4 -0
- package/dist/strings.js +12 -0
- package/dist/turbo.d.ts +5 -0
- package/dist/turbo.js +3 -0
- package/package.json +50 -0
package/dist/scroll.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export async function scrollToElement(element, { behavior = "smooth", block = "start", inline = "nearest" } = {}) {
|
|
2
|
+
element.scrollIntoView({ behavior, block, inline });
|
|
3
|
+
}
|
|
4
|
+
export async function scrollAbsoluteTop(element, { behavior = "smooth" } = {}) {
|
|
5
|
+
element.scrollTo({ top: 0, left: 0, behavior });
|
|
6
|
+
}
|
|
7
|
+
export async function scrollAbsoluteBottom(element, { behavior = "smooth" } = {}) {
|
|
8
|
+
if (element == window) {
|
|
9
|
+
element.scrollTo({ top: document.body.scrollHeight, left: 0, behavior });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
element.scrollTo({ top: element.scrollHeight, left: 0, behavior });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function scrollAbsoluteLeft(element, { behavior = "smooth" } = {}) {
|
|
16
|
+
element.scrollTo({ left: 0, behavior });
|
|
17
|
+
}
|
|
18
|
+
export async function scrollAbsoluteRight(element, { behavior = "smooth" } = {}) {
|
|
19
|
+
if (element == window) {
|
|
20
|
+
element.scrollTo({ left: document.body.scrollWidth, behavior });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
element.scrollTo({ left: element.scrollWidth, behavior });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function scrollUp(element, amount, { behavior = "smooth" } = {}) {
|
|
27
|
+
element.scrollBy({ top: -amount, left: 0, behavior });
|
|
28
|
+
}
|
|
29
|
+
export async function scrollDown(element, amount, { behavior = "smooth" } = {}) {
|
|
30
|
+
element.scrollBy({ top: amount, left: 0, behavior });
|
|
31
|
+
}
|
|
32
|
+
export async function scrollLeft(element, amount, { behavior = "smooth" } = {}) {
|
|
33
|
+
element.scrollBy({ top: 0, left: -amount, behavior });
|
|
34
|
+
}
|
|
35
|
+
export async function scrollRight(element, amount, { behavior = "smooth" } = {}) {
|
|
36
|
+
element.scrollBy({ top: 0, left: amount, behavior });
|
|
37
|
+
}
|
|
38
|
+
export function getScrollParent(node) {
|
|
39
|
+
if (!node) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (node == document.body) {
|
|
43
|
+
return window;
|
|
44
|
+
}
|
|
45
|
+
const overflowY = getComputedStyle(node).overflowY;
|
|
46
|
+
const isScrollable = overflowY !== "visible" && overflowY !== "hidden";
|
|
47
|
+
if (isScrollable && node.scrollHeight >= node.clientHeight) {
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
return getScrollParent(node.parentElement) || document.body;
|
|
51
|
+
}
|
package/dist/stimulus.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function controllerMethod(controller, methodName) {
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
const method = controller[methodName];
|
|
4
|
+
if (typeof method == 'function') {
|
|
5
|
+
return method;
|
|
6
|
+
}
|
|
7
|
+
else if (method != undefined) {
|
|
8
|
+
return () => method;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return () => void 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/strings.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function upperFirst(str) {
|
|
2
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3
|
+
}
|
|
4
|
+
export function lowerFirst(str) {
|
|
5
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
6
|
+
}
|
|
7
|
+
export function camelCase(str) {
|
|
8
|
+
return lowerFirst(str.replace(/[-_\s]([A-Za-z])/g, (g) => g[1].toUpperCase() + g.slice(2)));
|
|
9
|
+
}
|
|
10
|
+
export function pascalCase(str) {
|
|
11
|
+
return upperFirst(camelCase(str));
|
|
12
|
+
}
|
package/dist/turbo.d.ts
ADDED
package/dist/turbo.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stimulus-library/utilities",
|
|
3
|
+
"description": "A library of useful controllers for Stimulus",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"stimulusjs",
|
|
6
|
+
"stimulus-js",
|
|
7
|
+
"stimulus library",
|
|
8
|
+
"stimulus controller",
|
|
9
|
+
"ruby on rails",
|
|
10
|
+
"ruby-on-rails"
|
|
11
|
+
],
|
|
12
|
+
"version": "0.9.11",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Sub-Xaero",
|
|
16
|
+
"url": "https://github.com/Sub-Xaero/"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://sub-xaero.github.io/stimulus-library/",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/Sub-Xaero/stimulus-library"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"module": "dist/index.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"dev": "tsc --watch",
|
|
31
|
+
"prepack": "npm run build",
|
|
32
|
+
"release": "standard-version",
|
|
33
|
+
"test": "cypress run",
|
|
34
|
+
"test:treeshake": "agadoo dist"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@hotwired/stimulus": "^3.0.0",
|
|
38
|
+
"@stimulus-library/utilities": "*"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"agadoo": "^3.0.0",
|
|
42
|
+
"cypress": "^12.5.1",
|
|
43
|
+
"fast-glob": "^3.2.12",
|
|
44
|
+
"lerna": "^6.5.1",
|
|
45
|
+
"rimraf": "^4.1.2",
|
|
46
|
+
"standard-version": "^9.5.0",
|
|
47
|
+
"typescript": "^4.9.5",
|
|
48
|
+
"vite": "^4.1.1"
|
|
49
|
+
}
|
|
50
|
+
}
|