@studiometa/js-toolkit 3.0.0-alpha.1 → 3.0.0-alpha.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/Base/Base.d.ts +7 -7
- package/Base/Base.js +69 -35
- package/Base/Base.js.map +2 -2
- package/Base/features.d.ts +7 -1
- package/Base/features.js +10 -1
- package/Base/features.js.map +2 -2
- package/Base/index.d.ts +1 -0
- package/Base/index.js +4 -0
- package/Base/index.js.map +2 -2
- package/Base/managers/AbstractManager.d.ts +3 -3
- package/Base/managers/ChildrenManager.d.ts +6 -6
- package/Base/managers/ChildrenManager.js +34 -20
- package/Base/managers/ChildrenManager.js.map +2 -2
- package/Base/managers/EventsManager.d.ts +6 -28
- package/Base/managers/EventsManager.js +55 -67
- package/Base/managers/EventsManager.js.map +2 -2
- package/Base/managers/OptionsManager.d.ts +7 -7
- package/Base/managers/OptionsManager.js +32 -26
- package/Base/managers/OptionsManager.js.map +3 -3
- package/Base/managers/RefsManager.d.ts +1 -1
- package/Base/managers/RefsManager.js +23 -34
- package/Base/managers/RefsManager.js.map +3 -3
- package/Base/managers/ResponsiveOptionsManager.js +7 -4
- package/Base/managers/ResponsiveOptionsManager.js.map +2 -2
- package/Base/utils.d.ts +14 -5
- package/Base/utils.js +40 -22
- package/Base/utils.js.map +2 -2
- package/README.md +107 -6
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/index.js.map +2 -2
- package/decorators/withBreakpointManager.js +6 -4
- package/decorators/withBreakpointManager.js.map +2 -2
- package/decorators/withBreakpointObserver.d.ts +0 -1
- package/decorators/withBreakpointObserver.js +18 -11
- package/decorators/withBreakpointObserver.js.map +2 -2
- package/decorators/withIntersectionObserver.js +2 -4
- package/decorators/withIntersectionObserver.js.map +2 -2
- package/decorators/withMountOnMediaQuery.js +2 -2
- package/decorators/withMountOnMediaQuery.js.map +2 -2
- package/decorators/withMountWhenInView.js +2 -2
- package/decorators/withMountWhenInView.js.map +2 -2
- package/decorators/withName.d.ts +6 -0
- package/decorators/withName.js +12 -0
- package/decorators/withName.js.map +7 -0
- package/decorators/withResponsiveOptions.d.ts +3 -1
- package/decorators/withResponsiveOptions.js +22 -2
- package/decorators/withResponsiveOptions.js.map +2 -2
- package/helpers/createApp.d.ts +3 -5
- package/helpers/createApp.js +25 -11
- package/helpers/createApp.js.map +2 -2
- package/helpers/getDirectChildren.js +10 -5
- package/helpers/getDirectChildren.js.map +2 -2
- package/helpers/importWhenVisible.js +1 -2
- package/helpers/importWhenVisible.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +2 -4
- package/index.js.map +2 -2
- package/package.json +2 -2
- package/services/resize.js +2 -3
- package/services/resize.js.map +2 -2
- package/services/scroll.d.ts +14 -0
- package/services/scroll.js +31 -13
- package/services/scroll.js.map +2 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/index.js.map +2 -2
- package/utils/loadElement.d.ts +42 -0
- package/utils/loadElement.js +33 -0
- package/utils/loadElement.js.map +7 -0
- package/utils/math/createRange.d.ts +4 -0
- package/utils/math/createRange.js +13 -0
- package/utils/math/createRange.js.map +7 -0
- package/utils/math/index.d.ts +1 -0
- package/utils/math/index.js +2 -0
- package/utils/math/index.js.map +2 -2
- package/utils/memo.d.ts +5 -0
- package/utils/memo.js +14 -0
- package/utils/memo.js.map +7 -0
- package/utils/random.js +1 -1
- package/utils/random.js.map +1 -1
- package/utils/string/changeCase.d.ts +24 -0
- package/utils/string/changeCase.js +47 -0
- package/utils/string/changeCase.js.map +7 -0
- package/utils/string/index.d.ts +1 -0
- package/utils/string/index.js +1 -0
- package/utils/string/index.js.map +2 -2
- package/Base/managers/ActionManager.d.ts +0 -4
- package/Base/managers/ActionManager.js +0 -10
- package/Base/managers/ActionManager.js.map +0 -7
package/services/scroll.d.ts
CHANGED
|
@@ -7,26 +7,40 @@ export interface ScrollServiceProps {
|
|
|
7
7
|
x: boolean;
|
|
8
8
|
y: boolean;
|
|
9
9
|
};
|
|
10
|
+
changedX: boolean;
|
|
11
|
+
changedY: boolean;
|
|
10
12
|
last: {
|
|
11
13
|
x: number;
|
|
12
14
|
y: number;
|
|
13
15
|
};
|
|
16
|
+
lastX: number;
|
|
17
|
+
lastY: number;
|
|
14
18
|
delta: {
|
|
15
19
|
x: number;
|
|
16
20
|
y: number;
|
|
17
21
|
};
|
|
22
|
+
deltaX: number;
|
|
23
|
+
deltaY: number;
|
|
18
24
|
progress: {
|
|
19
25
|
x: number;
|
|
20
26
|
y: number;
|
|
21
27
|
};
|
|
28
|
+
progressX: number;
|
|
29
|
+
progressY: number;
|
|
22
30
|
max: {
|
|
23
31
|
x: number;
|
|
24
32
|
y: number;
|
|
25
33
|
};
|
|
34
|
+
maxX: number;
|
|
35
|
+
maxY: number;
|
|
26
36
|
direction: {
|
|
27
37
|
x: 'LEFT' | 'RIGHT' | 'NONE';
|
|
28
38
|
y: 'UP' | 'DOWN' | 'NONE';
|
|
29
39
|
};
|
|
40
|
+
isUp: boolean;
|
|
41
|
+
isRight: boolean;
|
|
42
|
+
isDown: boolean;
|
|
43
|
+
isLeft: boolean;
|
|
30
44
|
}
|
|
31
45
|
/**
|
|
32
46
|
* Use the scroll service.
|
package/services/scroll.js
CHANGED
|
@@ -10,18 +10,22 @@ function createScrollService() {
|
|
|
10
10
|
if (window.scrollX !== props.x) {
|
|
11
11
|
props.x = window.scrollX;
|
|
12
12
|
}
|
|
13
|
-
props.changed.x = props.x !== xLast;
|
|
14
|
-
props.changed.y = props.y !== yLast;
|
|
15
|
-
props.last.x = xLast;
|
|
16
|
-
props.last.y = yLast;
|
|
17
|
-
props.delta.x = props.x - xLast;
|
|
18
|
-
props.delta.y = props.y - yLast;
|
|
19
|
-
props.max.x = (document.scrollingElement || document.body).scrollWidth - window.innerWidth;
|
|
20
|
-
props.max.y = (document.scrollingElement || document.body).scrollHeight - window.innerHeight;
|
|
21
|
-
props.progress.x = props.max.x === 0 ? 1 : props.x / props.max.x;
|
|
22
|
-
props.progress.y = props.max.y === 0 ? 1 : props.y / props.max.y;
|
|
23
|
-
props.
|
|
24
|
-
props.
|
|
13
|
+
props.changed.x = props.changedX = props.x !== xLast;
|
|
14
|
+
props.changed.y = props.changedY = props.y !== yLast;
|
|
15
|
+
props.last.x = props.lastX = xLast;
|
|
16
|
+
props.last.y = props.lastY = yLast;
|
|
17
|
+
props.delta.x = props.deltaX = props.x - xLast;
|
|
18
|
+
props.delta.y = props.deltaY = props.y - yLast;
|
|
19
|
+
props.max.x = props.maxX = (document.scrollingElement || document.body).scrollWidth - window.innerWidth;
|
|
20
|
+
props.max.y = props.maxY = (document.scrollingElement || document.body).scrollHeight - window.innerHeight;
|
|
21
|
+
props.progress.x = props.progressX = props.max.x === 0 ? 1 : props.x / props.max.x;
|
|
22
|
+
props.progress.y = props.progressY = props.max.y === 0 ? 1 : props.y / props.max.y;
|
|
23
|
+
props.isUp = props.y < yLast;
|
|
24
|
+
props.isRight = props.x > xLast;
|
|
25
|
+
props.isDown = props.y > yLast;
|
|
26
|
+
props.isLeft = props.x < xLast;
|
|
27
|
+
props.direction.x = props.isRight ? "RIGHT" : props.isLeft ? "LEFT" : "NONE";
|
|
28
|
+
props.direction.y = props.isDown ? "DOWN" : props.isUp ? "UP" : "NONE";
|
|
25
29
|
return props;
|
|
26
30
|
}
|
|
27
31
|
const onScrollDebounced = debounce(() => {
|
|
@@ -39,26 +43,40 @@ function createScrollService() {
|
|
|
39
43
|
x: false,
|
|
40
44
|
y: false
|
|
41
45
|
},
|
|
46
|
+
changedX: false,
|
|
47
|
+
changedY: false,
|
|
42
48
|
last: {
|
|
43
49
|
x: window.scrollX,
|
|
44
50
|
y: window.scrollY
|
|
45
51
|
},
|
|
52
|
+
lastX: window.scrollX,
|
|
53
|
+
lastY: window.scrollY,
|
|
46
54
|
delta: {
|
|
47
55
|
x: 0,
|
|
48
56
|
y: 0
|
|
49
57
|
},
|
|
58
|
+
deltaX: 0,
|
|
59
|
+
deltaY: 0,
|
|
50
60
|
max: {
|
|
51
61
|
x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,
|
|
52
62
|
y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight
|
|
53
63
|
},
|
|
64
|
+
maxX: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,
|
|
65
|
+
maxY: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,
|
|
54
66
|
progress: {
|
|
55
67
|
x: 0,
|
|
56
68
|
y: 0
|
|
57
69
|
},
|
|
70
|
+
progressX: 0,
|
|
71
|
+
progressY: 0,
|
|
58
72
|
direction: {
|
|
59
73
|
x: "NONE",
|
|
60
74
|
y: "NONE"
|
|
61
|
-
}
|
|
75
|
+
},
|
|
76
|
+
isUp: false,
|
|
77
|
+
isRight: false,
|
|
78
|
+
isDown: false,
|
|
79
|
+
isLeft: false
|
|
62
80
|
},
|
|
63
81
|
init() {
|
|
64
82
|
document.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
package/services/scroll.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/services/scroll.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-use-before-define, @typescript-eslint/no-use-before-define */\nimport { useService } from './service.js';\nimport debounce from '../utils/debounce.js';\nimport type { ServiceInterface } from './index.js';\n\nexport type ScrollService = ServiceInterface<ScrollServiceProps>;\n\nexport interface ScrollServiceProps {\n x: number;\n y: number;\n changed: { x: boolean; y: boolean };\n last: { x: number; y: number };\n delta: { x: number; y: number };\n progress: { x: number; y: number };\n max: { x: number; y: number };\n direction: { x: 'LEFT' | 'RIGHT' | 'NONE'; y: 'UP' | 'DOWN' | 'NONE' };\n}\n\n/**\n * Create scroll service.\n */\nfunction createScrollService(): ScrollService {\n /**\n * Update props.\n */\n function updateProps(): ScrollServiceProps {\n const yLast = props.y;\n const xLast = props.x;\n\n // Check scroll Y\n if (window.scrollY !== props.y) {\n props.y = window.scrollY;\n }\n\n // Check scroll x\n if (window.scrollX !== props.x) {\n props.x = window.scrollX;\n }\n\n props.changed.x = props.x !== xLast;\n props.changed.y = props.y !== yLast;\n props.last.x = xLast;\n props.last.y = yLast;\n props.delta.x = props.x - xLast;\n props.delta.y = props.y - yLast;\n props.max.x = (document.scrollingElement || document.body).scrollWidth - window.innerWidth;\n props.max.y = (document.scrollingElement || document.body).scrollHeight - window.innerHeight;\n props.progress.x = props.max.x === 0 ? 1 : props.x / props.max.x;\n props.progress.y = props.max.y === 0 ? 1 : props.y / props.max.y;\n /* eslint-disable no-nested-ternary */\n props.direction.x = props.
|
|
5
|
-
"mappings": "AACA,SAAS,kBAAkB;AAC3B,OAAO,cAAc;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-use-before-define, @typescript-eslint/no-use-before-define */\nimport { useService } from './service.js';\nimport debounce from '../utils/debounce.js';\nimport type { ServiceInterface } from './index.js';\n\nexport type ScrollService = ServiceInterface<ScrollServiceProps>;\n\nexport interface ScrollServiceProps {\n x: number;\n y: number;\n changed: { x: boolean; y: boolean };\n changedX: boolean;\n changedY: boolean;\n last: { x: number; y: number };\n lastX: number;\n lastY: number;\n delta: { x: number; y: number };\n deltaX: number;\n deltaY: number;\n progress: { x: number; y: number };\n progressX: number;\n progressY: number;\n max: { x: number; y: number };\n maxX: number;\n maxY: number;\n direction: { x: 'LEFT' | 'RIGHT' | 'NONE'; y: 'UP' | 'DOWN' | 'NONE' };\n isUp: boolean;\n isRight: boolean;\n isDown: boolean;\n isLeft: boolean;\n}\n\n/**\n * Create scroll service.\n */\nfunction createScrollService(): ScrollService {\n /**\n * Update props.\n */\n function updateProps(): ScrollServiceProps {\n const yLast = props.y;\n const xLast = props.x;\n\n // Check scroll Y\n if (window.scrollY !== props.y) {\n props.y = window.scrollY;\n }\n\n // Check scroll x\n if (window.scrollX !== props.x) {\n props.x = window.scrollX;\n }\n\n props.changed.x = props.changedX = props.x !== xLast;\n props.changed.y = props.changedY = props.y !== yLast;\n props.last.x = props.lastX = xLast;\n props.last.y = props.lastY = yLast;\n props.delta.x = props.deltaX = props.x - xLast;\n props.delta.y = props.deltaY = props.y - yLast;\n props.max.x = props.maxX = (document.scrollingElement || document.body).scrollWidth - window.innerWidth;\n props.max.y = props.maxY = (document.scrollingElement || document.body).scrollHeight - window.innerHeight;\n props.progress.x = props.progressX = props.max.x === 0 ? 1 : props.x / props.max.x;\n props.progress.y = props.progressY = props.max.y === 0 ? 1 : props.y / props.max.y;\n props.isUp = props.y < yLast;\n props.isRight = props.x > xLast;\n props.isDown = props.y > yLast;\n props.isLeft = props.x < xLast;\n /* eslint-disable no-nested-ternary */\n props.direction.x = props.isRight ? 'RIGHT' : props.isLeft ? 'LEFT' : 'NONE';\n props.direction.y = props.isDown ? 'DOWN' : props.isUp ? 'UP' : 'NONE';\n /* eslint-enable no-nested-ternary */\n\n return props;\n }\n\n const onScrollDebounced = debounce(() => {\n trigger(updateProps());\n }, 100);\n\n /**\n * Scroll handler.\n */\n function onScroll() {\n trigger(updateProps());\n onScrollDebounced();\n }\n\n const { add, remove, has, props, trigger } = useService({\n props: {\n x: window.scrollX,\n y: window.scrollY,\n changed: {\n x: false,\n y: false,\n },\n changedX: false,\n changedY: false,\n last: {\n x: window.scrollX,\n y: window.scrollY,\n },\n lastX: window.scrollX,\n lastY: window.scrollY,\n delta: {\n x: 0,\n y: 0,\n },\n deltaX: 0,\n deltaY: 0,\n max: {\n x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,\n y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,\n },\n maxX: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,\n maxY: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,\n progress: {\n x: 0,\n y: 0,\n },\n progressX: 0,\n progressY: 0,\n direction: {\n x: 'NONE',\n y: 'NONE',\n },\n isUp: false,\n isRight: false,\n isDown: false,\n isLeft: false,\n } as ScrollServiceProps,\n init() {\n document.addEventListener('scroll', onScroll, { passive: true, capture: true });\n },\n kill() {\n document.removeEventListener('scroll', onScroll);\n },\n });\n\n return {\n add,\n remove,\n has,\n props: () => props,\n };\n}\n\nlet scroll;\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n */\nexport default function useScroll(): ScrollService {\n if (!scroll) {\n scroll = createScrollService();\n }\n\n return scroll;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../packages/global.d.ts","../packages/js-toolkit/index.ts","../packages/js-toolkit/base/base.ts","../packages/js-toolkit/base/features.ts","../packages/js-toolkit/base/index.ts","../packages/js-toolkit/base/types.ts","../packages/js-toolkit/base/utils.ts","../packages/js-toolkit/base/managers/abstractmanager.ts","../packages/js-toolkit/base/managers/childrenmanager.ts","../packages/js-toolkit/base/managers/eventsmanager.ts","../packages/js-toolkit/base/managers/optionsmanager.ts","../packages/js-toolkit/base/managers/refsmanager.ts","../packages/js-toolkit/base/managers/responsiveoptionsmanager.ts","../packages/js-toolkit/base/managers/servicesmanager.ts","../packages/js-toolkit/base/managers/index.ts","../packages/js-toolkit/decorators/index.ts","../packages/js-toolkit/decorators/withbreakpointmanager.ts","../packages/js-toolkit/decorators/withbreakpointobserver.ts","../packages/js-toolkit/decorators/withdrag.ts","../packages/js-toolkit/decorators/withextraconfig.ts","../packages/js-toolkit/decorators/withfreezedoptions.ts","../packages/js-toolkit/decorators/withintersectionobserver.ts","../packages/js-toolkit/decorators/withmountonmediaquery.ts","../packages/js-toolkit/decorators/withmountwheninview.ts","../packages/js-toolkit/decorators/withmountwhenprefersmotion.ts","../packages/js-toolkit/decorators/withname.ts","../packages/js-toolkit/decorators/withrelativepointer.ts","../packages/js-toolkit/decorators/withresponsiveoptions.ts","../packages/js-toolkit/decorators/withscrolledinview/index.ts","../packages/js-toolkit/decorators/withscrolledinview/types.ts","../packages/js-toolkit/decorators/withscrolledinview/utils.ts","../packages/js-toolkit/decorators/withscrolledinview/withscrolledinview.ts","../packages/js-toolkit/helpers/createapp.ts","../packages/js-toolkit/helpers/getclosestparent.ts","../packages/js-toolkit/helpers/getdirectchildren.ts","../packages/js-toolkit/helpers/getinstancefromelement.ts","../packages/js-toolkit/helpers/importoninteraction.ts","../packages/js-toolkit/helpers/importonmediaquery.ts","../packages/js-toolkit/helpers/importwhenidle.ts","../packages/js-toolkit/helpers/importwhenprefersmotion.ts","../packages/js-toolkit/helpers/importwhenvisible.ts","../packages/js-toolkit/helpers/index.ts","../packages/js-toolkit/helpers/utils.ts","../packages/js-toolkit/services/drag.ts","../packages/js-toolkit/services/index.ts","../packages/js-toolkit/services/key.ts","../packages/js-toolkit/services/load.ts","../packages/js-toolkit/services/pointer.ts","../packages/js-toolkit/services/raf.ts","../packages/js-toolkit/services/resize.ts","../packages/js-toolkit/services/scroll.ts","../packages/js-toolkit/services/service.ts","../packages/js-toolkit/utils/queue.ts","../packages/js-toolkit/utils/smartqueue.ts","../packages/js-toolkit/utils/debounce.ts","../packages/js-toolkit/utils/getcomponentresolver.ts","../packages/js-toolkit/utils/has.ts","../packages/js-toolkit/utils/history.ts","../packages/js-toolkit/utils/index.ts","../packages/js-toolkit/utils/is.ts","../packages/js-toolkit/utils/keycodes.ts","../packages/js-toolkit/utils/loadelement.ts","../packages/js-toolkit/utils/memo.ts","../packages/js-toolkit/utils/memoize.ts","../packages/js-toolkit/utils/nextframe.ts","../packages/js-toolkit/utils/nextmicrotask.ts","../packages/js-toolkit/utils/nexttick.ts","../packages/js-toolkit/utils/noop.ts","../packages/js-toolkit/utils/random.ts","../packages/js-toolkit/utils/scheduler.ts","../packages/js-toolkit/utils/scrollto.ts","../packages/js-toolkit/utils/throttle.ts","../packages/js-toolkit/utils/trapfocus.ts","../packages/js-toolkit/utils/tween.ts","../packages/js-toolkit/utils/wait.ts","../packages/js-toolkit/utils/collide/boundingrecttocircle.ts","../packages/js-toolkit/utils/collide/collidecirclecircle.ts","../packages/js-toolkit/utils/collide/collidecirclerect.ts","../packages/js-toolkit/utils/collide/collidepointcircle.ts","../packages/js-toolkit/utils/collide/collidepointrect.ts","../packages/js-toolkit/utils/collide/colliderectrect.ts","../packages/js-toolkit/utils/collide/index.ts","../packages/js-toolkit/utils/css/animate.ts","../packages/js-toolkit/utils/css/classes.ts","../packages/js-toolkit/utils/css/getoffsetsizes.ts","../packages/js-toolkit/utils/css/index.ts","../packages/js-toolkit/utils/css/matrix.ts","../packages/js-toolkit/utils/css/styles.ts","../packages/js-toolkit/utils/css/transform.ts","../packages/js-toolkit/utils/css/transition.ts","../packages/js-toolkit/utils/css/utils.ts","../packages/js-toolkit/utils/dom/ancestors.ts","../packages/js-toolkit/utils/dom/index.ts","../packages/js-toolkit/utils/math/clamp.ts","../packages/js-toolkit/utils/math/clamp01.ts","../packages/js-toolkit/utils/math/createeases.ts","../packages/js-toolkit/utils/math/createrange.ts","../packages/js-toolkit/utils/math/damp.ts","../packages/js-toolkit/utils/math/ease.ts","../packages/js-toolkit/utils/math/index.ts","../packages/js-toolkit/utils/math/inertiafinalvalue.ts","../packages/js-toolkit/utils/math/lerp.ts","../packages/js-toolkit/utils/math/map.ts","../packages/js-toolkit/utils/math/mean.ts","../packages/js-toolkit/utils/math/round.ts","../packages/js-toolkit/utils/object/getallproperties.ts","../packages/js-toolkit/utils/string/changecase.ts","../packages/js-toolkit/utils/string/endswith.ts","../packages/js-toolkit/utils/string/index.ts","../packages/js-toolkit/utils/string/startswith.ts","../packages/js-toolkit/utils/string/withleadingcharacters.ts","../packages/js-toolkit/utils/string/withleadingslash.ts","../packages/js-toolkit/utils/string/withtrailingcharacters.ts","../packages/js-toolkit/utils/string/withtrailingslash.ts","../packages/js-toolkit/utils/string/withoutleadingcharacters.ts","../packages/js-toolkit/utils/string/withoutleadingcharactersrecursive.ts","../packages/js-toolkit/utils/string/withoutleadingslash.ts","../packages/js-toolkit/utils/string/withouttrailingcharacters.ts","../packages/js-toolkit/utils/string/withouttrailingcharactersrecursive.ts","../packages/js-toolkit/utils/string/withouttrailingslash.ts"],"version":"5.6.3"}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
package/utils/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as debounce } from './debounce.js';\nexport * from './trapFocus.js';\nexport { default as keyCodes } from './keyCodes.js';\nexport { default as memoize } from './memoize.js';\nexport { nextFrame } from './nextFrame.js';\nexport { nextTick } from './nextTick.js';\nexport { nextMicrotask } from './nextMicrotask.js';\nexport { default as throttle } from './throttle.js';\nexport { scrollTo } from './scrollTo.js';\nexport { default as getComponentResolver } from './getComponentResolver.js';\nexport * from './is.js';\nexport * from './has.js';\nexport * from './css/index.js';\nexport {\n objectToURLSearchParams,\n push as historyPush,\n replace as historyReplace,\n} from './history.js';\nexport * from './collide/index.js';\nexport * from './math/index.js';\nexport * from './string/index.js';\nexport * from './scheduler.js';\nexport * from './noop.js';\nexport { tween } from './tween.js';\nexport { Queue } from './Queue.js';\nexport { SmartQueue } from './SmartQueue.js';\nexport * from './dom/index.js';\nexport * from './wait.js';\nexport * from './random.js';\n"],
|
|
5
|
-
"mappings": "AAAA,SAAoB,WAAXA,gBAA2B;AACpC,cAAc;AACd,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAoB,WAAXA,gBAA2B;AACpC,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAAuC;AAChD,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACQ;AAAA,EACG;AAAA,OACN;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export { default as debounce } from './debounce.js';\nexport * from './trapFocus.js';\nexport { default as keyCodes } from './keyCodes.js';\nexport { default as memoize } from './memoize.js';\nexport { nextFrame } from './nextFrame.js';\nexport { nextTick } from './nextTick.js';\nexport { nextMicrotask } from './nextMicrotask.js';\nexport { default as throttle } from './throttle.js';\nexport { scrollTo } from './scrollTo.js';\nexport { default as getComponentResolver } from './getComponentResolver.js';\nexport * from './is.js';\nexport * from './has.js';\nexport * from './css/index.js';\nexport {\n objectToURLSearchParams,\n push as historyPush,\n replace as historyReplace,\n} from './history.js';\nexport * from './collide/index.js';\nexport * from './math/index.js';\nexport * from './string/index.js';\nexport * from './scheduler.js';\nexport * from './noop.js';\nexport { tween } from './tween.js';\nexport { Queue } from './Queue.js';\nexport { SmartQueue } from './SmartQueue.js';\nexport * from './dom/index.js';\nexport * from './wait.js';\nexport * from './random.js';\nexport * from './memo.js';\nexport * from './loadElement.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAoB,WAAXA,gBAA2B;AACpC,cAAc;AACd,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAoB,WAAXA,gBAA2B;AACpC,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAAuC;AAChD,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACQ;AAAA,EACG;AAAA,OACN;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type LoadableElements = {
|
|
2
|
+
embed: HTMLEmbedElement;
|
|
3
|
+
iframe: HTMLIFrameElement;
|
|
4
|
+
img: HTMLImageElement;
|
|
5
|
+
link: HTMLLinkElement;
|
|
6
|
+
script: HTMLScriptElement;
|
|
7
|
+
track: HTMLTrackElement;
|
|
8
|
+
};
|
|
9
|
+
export type LoadableElementsNames = keyof LoadableElements;
|
|
10
|
+
export type LoadElementsOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* An HTML element where the created element will be appended.
|
|
13
|
+
*/
|
|
14
|
+
appendTo?: HTMLElement;
|
|
15
|
+
};
|
|
16
|
+
export type LoadElementsReturnType<T extends LoadableElementsNames> = Promise<{
|
|
17
|
+
event: Event;
|
|
18
|
+
element: LoadableElements[T];
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Load the given source for the given type of element.
|
|
22
|
+
* @todo manage memo
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadElement<T extends LoadableElementsNames>(src: string, type: T, { appendTo }?: LoadElementsOptions): LoadElementsReturnType<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Load the given source as an `<img>` element.
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadImage(src: string, options?: LoadElementsOptions): LoadElementsReturnType<"img">;
|
|
29
|
+
/**
|
|
30
|
+
* Load the given source as an `<iframe>` element.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadIframe(src: string, options?: LoadElementsOptions): LoadElementsReturnType<"iframe">;
|
|
33
|
+
/**
|
|
34
|
+
* Load the given source as a `<link>` element.
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadLink(src: string, options?: LoadElementsOptions): LoadElementsReturnType<"link">;
|
|
37
|
+
/**
|
|
38
|
+
* Load the given source as a `<script>` element. The generated element is
|
|
39
|
+
* appended to `document.head` by default, as a script element needs
|
|
40
|
+
* to be inserted in the DOM to load.
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadScript(src: string, options?: LoadElementsOptions): LoadElementsReturnType<"script">;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function loadElement(src, type, { appendTo = null } = {}) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const eventOptions = { once: true };
|
|
4
|
+
const prop = type === "link" ? "href" : "src";
|
|
5
|
+
const element = document.createElement(type);
|
|
6
|
+
element.addEventListener("load", (event) => resolve({ event, element }), eventOptions);
|
|
7
|
+
element.addEventListener("error", (event) => reject({ event, element }), eventOptions);
|
|
8
|
+
element[prop] = src;
|
|
9
|
+
if (appendTo) {
|
|
10
|
+
appendTo.append(element);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function loadImage(src, options) {
|
|
15
|
+
return loadElement(src, "img", options);
|
|
16
|
+
}
|
|
17
|
+
function loadIframe(src, options) {
|
|
18
|
+
return loadElement(src, "iframe", options);
|
|
19
|
+
}
|
|
20
|
+
function loadLink(src, options) {
|
|
21
|
+
return loadElement(src, "link", options);
|
|
22
|
+
}
|
|
23
|
+
function loadScript(src, options) {
|
|
24
|
+
return loadElement(src, "script", { appendTo: document.head, ...options });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
loadElement,
|
|
28
|
+
loadIframe,
|
|
29
|
+
loadImage,
|
|
30
|
+
loadLink,
|
|
31
|
+
loadScript
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=loadElement.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/js-toolkit/utils/loadElement.ts"],
|
|
4
|
+
"sourcesContent": ["export type LoadableElements = {\n embed: HTMLEmbedElement;\n iframe: HTMLIFrameElement;\n img: HTMLImageElement;\n link: HTMLLinkElement;\n script: HTMLScriptElement;\n track: HTMLTrackElement;\n};\n\nexport type LoadableElementsNames = keyof LoadableElements;\n\nexport type LoadElementsOptions = {\n /**\n * An HTML element where the created element will be appended.\n */\n appendTo?: HTMLElement;\n};\n\nexport type LoadElementsReturnType<T extends LoadableElementsNames> = Promise<{\n event: Event;\n element: LoadableElements[T];\n}>;\n\n/**\n * Load the given source for the given type of element.\n * @todo manage memo\n */\nexport function loadElement<T extends LoadableElementsNames>(\n src: string,\n type: T,\n { appendTo = null }: LoadElementsOptions = {},\n): LoadElementsReturnType<T> {\n return new Promise((resolve, reject) => {\n const eventOptions = { once: true };\n const prop = type === 'link' ? 'href' : 'src';\n const element = document.createElement(type);\n element.addEventListener('load', (event) => resolve({ event, element }), eventOptions);\n element.addEventListener('error', (event) => reject({ event, element }), eventOptions);\n element[prop] = src;\n if (appendTo) {\n appendTo.append(element);\n }\n });\n}\n\n/**\n * Load the given source as an `<img>` element.\n */\nexport function loadImage(src: string, options?: LoadElementsOptions) {\n return loadElement(src, 'img', options);\n}\n\n/**\n * Load the given source as an `<iframe>` element.\n */\nexport function loadIframe(src: string, options?: LoadElementsOptions) {\n return loadElement(src, 'iframe', options);\n}\n\n/**\n * Load the given source as a `<link>` element.\n */\nexport function loadLink(src: string, options?: LoadElementsOptions) {\n return loadElement(src, 'link', options);\n}\n\n/**\n * Load the given source as a `<script>` element. The generated element is\n * appended to `document.head` by default, as a script element needs\n * to be inserted in the DOM to load.\n */\nexport function loadScript(src: string, options?: LoadElementsOptions) {\n return loadElement(src, 'script', { appendTo: document.head, ...options });\n}\n"],
|
|
5
|
+
"mappings": "AA2BO,SAAS,YACd,KACA,MACA,EAAE,WAAW,KAAK,IAAyB,CAAC,GACjB;AAC3B,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,eAAe,EAAE,MAAM,KAAK;AAClC,UAAM,OAAO,SAAS,SAAS,SAAS;AACxC,UAAM,UAAU,SAAS,cAAc,IAAI;AAC3C,YAAQ,iBAAiB,QAAQ,CAAC,UAAU,QAAQ,EAAE,OAAO,QAAQ,CAAC,GAAG,YAAY;AACrF,YAAQ,iBAAiB,SAAS,CAAC,UAAU,OAAO,EAAE,OAAO,QAAQ,CAAC,GAAG,YAAY;AACrF,YAAQ,IAAI,IAAI;AAChB,QAAI,UAAU;AACZ,eAAS,OAAO,OAAO;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AAKO,SAAS,UAAU,KAAa,SAA+B;AACpE,SAAO,YAAY,KAAK,OAAO,OAAO;AACxC;AAKO,SAAS,WAAW,KAAa,SAA+B;AACrE,SAAO,YAAY,KAAK,UAAU,OAAO;AAC3C;AAKO,SAAS,SAAS,KAAa,SAA+B;AACnE,SAAO,YAAY,KAAK,QAAQ,OAAO;AACzC;AAOO,SAAS,WAAW,KAAa,SAA+B;AACrE,SAAO,YAAY,KAAK,UAAU,EAAE,UAAU,SAAS,MAAM,GAAG,QAAQ,CAAC;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/js-toolkit/utils/math/createRange.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Create an array from a given range and with the given incremental step.\n */\nexport function createRange(min: number, max: number, step: number): number[] {\n const result: number[] = [];\n let value = min;\n\n while (value <= max) {\n result.push(value);\n value += step;\n }\n\n return result;\n}\n"],
|
|
5
|
+
"mappings": "AAGO,SAAS,YAAY,KAAa,KAAa,MAAwB;AAC5E,QAAM,SAAmB,CAAC;AAC1B,MAAI,QAAQ;AAEZ,SAAO,SAAS,KAAK;AACnB,WAAO,KAAK,KAAK;AACjB,aAAS;AAAA,EACX;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/utils/math/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as ease from './ease.js';
|
|
2
2
|
export * from './createEases.js';
|
|
3
3
|
export * from './ease.js';
|
|
4
|
+
export { createRange } from './createRange.js';
|
|
4
5
|
export { default as clamp } from './clamp.js';
|
|
5
6
|
export { default as clamp01 } from './clamp01.js';
|
|
6
7
|
export { default as damp } from './damp.js';
|
package/utils/math/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as ease from "./ease.js";
|
|
2
2
|
export * from "./createEases.js";
|
|
3
3
|
export * from "./ease.js";
|
|
4
|
+
import { createRange } from "./createRange.js";
|
|
4
5
|
import { default as default2 } from "./clamp.js";
|
|
5
6
|
import { default as default3 } from "./clamp01.js";
|
|
6
7
|
import { default as default4 } from "./damp.js";
|
|
@@ -12,6 +13,7 @@ import { mean } from "./mean.js";
|
|
|
12
13
|
export {
|
|
13
14
|
default2 as clamp,
|
|
14
15
|
default3 as clamp01,
|
|
16
|
+
createRange,
|
|
15
17
|
default4 as damp,
|
|
16
18
|
ease,
|
|
17
19
|
default5 as inertiaFinalValue,
|
package/utils/math/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/math/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * as ease from './ease.js';\nexport * from './createEases.js';\nexport * from './ease.js';\nexport { default as clamp } from './clamp.js';\nexport { default as clamp01 } from './clamp01.js';\nexport { default as damp } from './damp.js';\nexport { default as inertiaFinalValue } from './inertiaFinalValue.js';\nexport { default as lerp } from './lerp.js';\nexport { default as map } from './map.js';\nexport { default as round } from './round.js';\nexport { mean } from './mean.js';\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,UAAU;AACtB,cAAc;AACd,cAAc;AACd,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAA0B;AACnC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAsB;AAC/B,SAAoB,WAAXA,gBAAwB;AACjC,SAAS,YAAY;",
|
|
4
|
+
"sourcesContent": ["export * as ease from './ease.js';\nexport * from './createEases.js';\nexport * from './ease.js';\nexport { createRange } from './createRange.js';\nexport { default as clamp } from './clamp.js';\nexport { default as clamp01 } from './clamp01.js';\nexport { default as damp } from './damp.js';\nexport { default as inertiaFinalValue } from './inertiaFinalValue.js';\nexport { default as lerp } from './lerp.js';\nexport { default as map } from './map.js';\nexport { default as round } from './round.js';\nexport { mean } from './mean.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,UAAU;AACtB,cAAc;AACd,cAAc;AACd,SAAS,mBAAmB;AAC5B,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAA0B;AACnC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAsB;AAC/B,SAAoB,WAAXA,gBAAwB;AACjC,SAAS,YAAY;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
package/utils/memo.d.ts
ADDED
package/utils/memo.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function memo(fn) {
|
|
2
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3
|
+
return function cached(...args) {
|
|
4
|
+
const key = args.join("");
|
|
5
|
+
if (!cache.has(key)) {
|
|
6
|
+
cache.set(key, fn(...args));
|
|
7
|
+
}
|
|
8
|
+
return cache.get(key);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
memo
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=memo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/js-toolkit/utils/memo.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Memoize the result of a function with a single argument indefinitely.\n * This is a simpler implementation of the `memoize` function.\n */\nexport function memo<T extends (...args: unknown[]) => unknown>(fn: T): T {\n const cache = new Map<string, ReturnType<T>>();\n\n // @ts-ignore\n return function cached(...args) {\n const key = args.join('');\n if (!cache.has(key)) {\n cache.set(key, fn(...args) as ReturnType<T>);\n }\n return cache.get(key);\n };\n}\n"],
|
|
5
|
+
"mappings": "AAIO,SAAS,KAAgD,IAAU;AACxE,QAAM,QAAQ,oBAAI,IAA2B;AAG7C,SAAO,SAAS,UAAU,MAAM;AAC9B,UAAM,MAAM,KAAK,KAAK,EAAE;AACxB,QAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AACnB,YAAM,IAAI,KAAK,GAAG,GAAG,IAAI,CAAkB;AAAA,IAC7C;AACA,WAAO,MAAM,IAAI,GAAG;AAAA,EACtB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/utils/random.js
CHANGED
package/utils/random.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/random.ts"],
|
|
4
|
-
"sourcesContent": ["import { isArray, isString } from './is';\n\n/**\n * Get a random integer between bounds\n *\n * @param {number} a Lower bound\n * @param {number} b Upper bound\n * @returns {number}\n */\nexport function randomInt(a: number, b = 0): number {\n return Math.floor(Math.random() * (a - b + 1)) + b;\n}\n\n/**\n * Get a random item of an array or a random character of a string\n *\n * @param {T[] | string} items Array or string\n * @returns {T | undefined}\n */\nexport function randomItem<T>(items: T[] | string): T | string | undefined {\n if (!isArray(items) && !isString(items)) {\n throw new Error('randomItem() expects an array or a string as argument.');\n }\n return items.length > 0 ? items[randomInt(items.length - 1)] : undefined;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { isArray, isString } from './is.js';\n\n/**\n * Get a random integer between bounds\n *\n * @param {number} a Lower bound\n * @param {number} b Upper bound\n * @returns {number}\n */\nexport function randomInt(a: number, b = 0): number {\n return Math.floor(Math.random() * (a - b + 1)) + b;\n}\n\n/**\n * Get a random item of an array or a random character of a string\n *\n * @param {T[] | string} items Array or string\n * @returns {T | undefined}\n */\nexport function randomItem<T>(items: T[] | string): T | string | undefined {\n if (!isArray(items) && !isString(items)) {\n throw new Error('randomItem() expects an array or a string as argument.');\n }\n return items.length > 0 ? items[randomInt(items.length - 1)] : undefined;\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS,gBAAgB;AAS3B,SAAS,UAAU,GAAW,IAAI,GAAW;AAClD,SAAO,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,IAAI,EAAE,IAAI;AACnD;AAQO,SAAS,WAAc,OAA6C;AACzE,MAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,SAAS,KAAK,GAAG;AACvC,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,SAAO,MAAM,SAAS,IAAI,MAAM,UAAU,MAAM,SAAS,CAAC,CAAC,IAAI;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to lowercase.
|
|
3
|
+
*/
|
|
4
|
+
export declare function lowerCase(string: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a string to UPPERCASE.
|
|
7
|
+
*/
|
|
8
|
+
export declare function upperCase(string: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Convert a string to camelCase.
|
|
11
|
+
*/
|
|
12
|
+
export declare const camelCase: (string: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a string to PascalCase.
|
|
15
|
+
*/
|
|
16
|
+
export declare const pascalCase: (string: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a string to snake_case.
|
|
19
|
+
*/
|
|
20
|
+
export declare const snakeCase: (string: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a string to dash-case.
|
|
23
|
+
*/
|
|
24
|
+
export declare const dashCase: (string: string) => string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { memo } from "../memo.js";
|
|
2
|
+
const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
3
|
+
const SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
4
|
+
const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
5
|
+
const SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
6
|
+
function split(value) {
|
|
7
|
+
let result = value.trim();
|
|
8
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
9
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
10
|
+
let start = 0;
|
|
11
|
+
let end = result.length;
|
|
12
|
+
while (result.charAt(start) === "\0") start++;
|
|
13
|
+
if (start === end) return [];
|
|
14
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
15
|
+
return result.slice(start, end).split(/\0/g);
|
|
16
|
+
}
|
|
17
|
+
function delimitedCase(string, delimiter) {
|
|
18
|
+
return split(string).map((word) => lowerCase(word)).join(delimiter);
|
|
19
|
+
}
|
|
20
|
+
function lowerCase(string) {
|
|
21
|
+
return string.toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
function upperCase(string) {
|
|
24
|
+
return string.toUpperCase();
|
|
25
|
+
}
|
|
26
|
+
const camelCase = memo(function camelCase2(string) {
|
|
27
|
+
const result = pascalCase(string);
|
|
28
|
+
return lowerCase(result[0]) + result.slice(1);
|
|
29
|
+
});
|
|
30
|
+
const pascalCase = memo(function pascalCase2(string) {
|
|
31
|
+
return split(string).map((word) => upperCase(word[0]) + lowerCase(word.slice(1))).join("");
|
|
32
|
+
});
|
|
33
|
+
const snakeCase = memo(function snakeCase2(string) {
|
|
34
|
+
return delimitedCase(string, "_");
|
|
35
|
+
});
|
|
36
|
+
const dashCase = memo(function dashCase2(string) {
|
|
37
|
+
return delimitedCase(string, "-");
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
camelCase,
|
|
41
|
+
dashCase,
|
|
42
|
+
lowerCase,
|
|
43
|
+
pascalCase,
|
|
44
|
+
snakeCase,
|
|
45
|
+
upperCase
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=changeCase.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/js-toolkit/utils/string/changeCase.ts"],
|
|
4
|
+
"sourcesContent": ["import { memo } from '../memo.js';\n\nconst SPLIT_LOWER_UPPER_RE = /([\\p{Ll}\\d])(\\p{Lu})/gu;\nconst SPLIT_UPPER_UPPER_RE = /(\\p{Lu})([\\p{Lu}][\\p{Ll}])/gu;\nconst DEFAULT_STRIP_REGEXP = /[^\\p{L}\\d]+/giu;\nconst SPLIT_REPLACE_VALUE = '$1\\0$2';\n\n/**\n * Split function from the `change-case` package.\n * @see https://github.com/blakeembrey/change-case\n */\nfunction split(value: string) {\n let result = value.trim();\n\n result = result\n .replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)\n .replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);\n\n result = result.replace(DEFAULT_STRIP_REGEXP, '\\0');\n\n let start = 0;\n let end = result.length;\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === '\\0') start++;\n if (start === end) return [];\n while (result.charAt(end - 1) === '\\0') end--;\n\n return result.slice(start, end).split(/\\0/g);\n}\n\n/**\n * Convert a string to lowercase and join each word with the given delimiter.\n */\nfunction delimitedCase(string: string, delimiter: string): string {\n return split(string)\n .map((word) => lowerCase(word))\n .join(delimiter);\n}\n/**\n * Convert a string to lowercase.\n */\nexport function lowerCase(string: string): string {\n return string.toLowerCase();\n}\n\n/**\n * Convert a string to UPPERCASE.\n */\nexport function upperCase(string: string): string {\n return string.toUpperCase();\n}\n\n/**\n * Convert a string to camelCase.\n */\nexport const camelCase = memo(function camelCase(string: string): string {\n const result = pascalCase(string);\n return lowerCase(result[0]) + result.slice(1);\n});\n\n/**\n * Convert a string to PascalCase.\n */\nexport const pascalCase = memo(function pascalCase(string: string): string {\n return split(string)\n .map((word) => upperCase(word[0]) + lowerCase(word.slice(1)))\n .join('');\n});\n\n/**\n * Convert a string to snake_case.\n */\nexport const snakeCase = memo(function snakeCase(string: string): string {\n return delimitedCase(string, '_');\n});\n\n/**\n * Convert a string to dash-case.\n */\nexport const dashCase = memo(function dashCase(string: string): string {\n return delimitedCase(string, '-');\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAM5B,SAAS,MAAM,OAAe;AAC5B,MAAI,SAAS,MAAM,KAAK;AAExB,WAAS,OACN,QAAQ,sBAAsB,mBAAmB,EACjD,QAAQ,sBAAsB,mBAAmB;AAEpD,WAAS,OAAO,QAAQ,sBAAsB,IAAI;AAElD,MAAI,QAAQ;AACZ,MAAI,MAAM,OAAO;AAGjB,SAAO,OAAO,OAAO,KAAK,MAAM,KAAM;AACtC,MAAI,UAAU,IAAK,QAAO,CAAC;AAC3B,SAAO,OAAO,OAAO,MAAM,CAAC,MAAM,KAAM;AAExC,SAAO,OAAO,MAAM,OAAO,GAAG,EAAE,MAAM,KAAK;AAC7C;AAKA,SAAS,cAAc,QAAgB,WAA2B;AAChE,SAAO,MAAM,MAAM,EAChB,IAAI,CAAC,SAAS,UAAU,IAAI,CAAC,EAC7B,KAAK,SAAS;AACnB;AAIO,SAAS,UAAU,QAAwB;AAChD,SAAO,OAAO,YAAY;AAC5B;AAKO,SAAS,UAAU,QAAwB;AAChD,SAAO,OAAO,YAAY;AAC5B;AAKO,MAAM,YAAY,KAAK,SAASA,WAAU,QAAwB;AACvE,QAAM,SAAS,WAAW,MAAM;AAChC,SAAO,UAAU,OAAO,CAAC,CAAC,IAAI,OAAO,MAAM,CAAC;AAC9C,CAAC;AAKM,MAAM,aAAa,KAAK,SAASC,YAAW,QAAwB;AACzE,SAAO,MAAM,MAAM,EAChB,IAAI,CAAC,SAAS,UAAU,KAAK,CAAC,CAAC,IAAI,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,EAC3D,KAAK,EAAE;AACZ,CAAC;AAKM,MAAM,YAAY,KAAK,SAASC,WAAU,QAAwB;AACvE,SAAO,cAAc,QAAQ,GAAG;AAClC,CAAC;AAKM,MAAM,WAAW,KAAK,SAASC,UAAS,QAAwB;AACrE,SAAO,cAAc,QAAQ,GAAG;AAClC,CAAC;",
|
|
6
|
+
"names": ["camelCase", "pascalCase", "snakeCase", "dashCase"]
|
|
7
|
+
}
|
package/utils/string/index.d.ts
CHANGED
package/utils/string/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { default as default10 } from "./withTrailingCharacters.js";
|
|
|
10
10
|
import { default as default11 } from "./withTrailingSlash.js";
|
|
11
11
|
export * from "./startsWith.js";
|
|
12
12
|
export * from "./endsWith.js";
|
|
13
|
+
export * from "./changeCase.js";
|
|
13
14
|
export {
|
|
14
15
|
default2 as withLeadingCharacters,
|
|
15
16
|
default3 as withLeadingSlash,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as withLeadingCharacters } from './withLeadingCharacters.js';\nexport { default as withLeadingSlash } from './withLeadingSlash.js';\nexport { default as withoutLeadingCharacters } from './withoutLeadingCharacters.js';\nexport { default as withoutLeadingCharactersRecursive } from './withoutLeadingCharactersRecursive.js';\nexport { default as withoutLeadingSlash } from './withoutLeadingSlash.js';\nexport { default as withoutTrailingCharacters } from './withoutTrailingCharacters.js';\nexport { default as withoutTrailingCharactersRecursive } from './withoutTrailingCharactersRecursive.js';\nexport { default as withoutTrailingSlash } from './withoutTrailingSlash.js';\nexport { default as withTrailingCharacters } from './withTrailingCharacters.js';\nexport { default as withTrailingSlash } from './withTrailingSlash.js';\nexport * from './startsWith.js';\nexport * from './endsWith.js';\n"],
|
|
5
|
-
"mappings": "AAAA,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAA2C;AACpD,SAAoB,WAAXA,gBAAoD;AAC7D,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAAqD;AAC9D,SAAoB,WAAXA,gBAAuC;AAChD,SAAoB,WAAXA,iBAAyC;AAClD,SAAoB,WAAXA,iBAAoC;AAC7C,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export { default as withLeadingCharacters } from './withLeadingCharacters.js';\nexport { default as withLeadingSlash } from './withLeadingSlash.js';\nexport { default as withoutLeadingCharacters } from './withoutLeadingCharacters.js';\nexport { default as withoutLeadingCharactersRecursive } from './withoutLeadingCharactersRecursive.js';\nexport { default as withoutLeadingSlash } from './withoutLeadingSlash.js';\nexport { default as withoutTrailingCharacters } from './withoutTrailingCharacters.js';\nexport { default as withoutTrailingCharactersRecursive } from './withoutTrailingCharactersRecursive.js';\nexport { default as withoutTrailingSlash } from './withoutTrailingSlash.js';\nexport { default as withTrailingCharacters } from './withTrailingCharacters.js';\nexport { default as withTrailingSlash } from './withTrailingSlash.js';\nexport * from './startsWith.js';\nexport * from './endsWith.js';\nexport * from './changeCase.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAA2C;AACpD,SAAoB,WAAXA,gBAAoD;AAC7D,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAAqD;AAC9D,SAAoB,WAAXA,gBAAuC;AAChD,SAAoB,WAAXA,iBAAyC;AAClD,SAAoB,WAAXA,iBAAoC;AAC7C,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../packages/js-toolkit/Base/managers/ActionManager.ts"],
|
|
4
|
-
"sourcesContent": ["import { AbstractManager } from './AbstractManager.js';\n\nexport class ActionManager extends AbstractManager {\n registerAll() {\n this.__element.querySelectorAll('[data-on]');\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAEzB,MAAM,sBAAsB,gBAAgB;AAAA,EACjD,cAAc;AACZ,SAAK,UAAU,iBAAiB,WAAW;AAAA,EAC7C;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|