@studiometa/js-toolkit 2.11.2 → 3.0.0-alpha.1
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 +2 -2
- package/Base/Base.js +142 -79
- package/Base/Base.js.map +2 -2
- package/Base/features.d.ts +10 -2
- package/Base/features.js +23 -1
- package/Base/features.js.map +2 -2
- package/Base/managers/AbstractManager.d.ts +3 -3
- package/Base/managers/AbstractManager.js +21 -0
- package/Base/managers/AbstractManager.js.map +1 -1
- package/Base/managers/ActionManager.d.ts +4 -0
- package/Base/managers/ActionManager.js +10 -0
- package/Base/managers/ActionManager.js.map +7 -0
- package/Base/managers/ChildrenManager.d.ts +1 -1
- package/Base/managers/ChildrenManager.js +41 -8
- package/Base/managers/ChildrenManager.js.map +2 -2
- package/Base/managers/EventsManager.js +88 -7
- package/Base/managers/EventsManager.js.map +2 -2
- package/Base/managers/OptionsManager.js +25 -2
- package/Base/managers/OptionsManager.js.map +2 -2
- package/Base/managers/RefsManager.js +27 -6
- package/Base/managers/RefsManager.js.map +2 -2
- package/Base/managers/ResponsiveOptionsManager.js +22 -6
- package/Base/managers/ResponsiveOptionsManager.js.map +2 -2
- package/Base/managers/ServicesManager.d.ts +2 -4
- package/Base/managers/ServicesManager.js +56 -7
- package/Base/managers/ServicesManager.js.map +2 -2
- package/Base/utils.js +5 -1
- package/Base/utils.js.map +2 -2
- package/decorators/index.d.ts +0 -1
- package/decorators/index.js +0 -1
- package/decorators/index.js.map +2 -2
- package/decorators/withBreakpointManager.js +14 -4
- package/decorators/withBreakpointManager.js.map +2 -2
- package/decorators/withBreakpointObserver.js +13 -3
- package/decorators/withBreakpointObserver.js.map +2 -2
- package/decorators/withDrag.js +6 -0
- package/decorators/withDrag.js.map +1 -1
- package/decorators/withExtraConfig.js +3 -0
- package/decorators/withExtraConfig.js.map +1 -1
- package/decorators/withFreezedOptions.js +8 -0
- package/decorators/withFreezedOptions.js.map +1 -1
- package/decorators/withIntersectionObserver.js +10 -1
- package/decorators/withIntersectionObserver.js.map +2 -2
- package/decorators/withMountOnMediaQuery.js +17 -1
- package/decorators/withMountOnMediaQuery.js.map +2 -2
- package/decorators/withMountWhenInView.js +22 -1
- package/decorators/withMountWhenInView.js.map +2 -2
- package/decorators/withRelativePointer.js +6 -0
- package/decorators/withRelativePointer.js.map +1 -1
- package/decorators/withResponsiveOptions.js +3 -0
- package/decorators/withResponsiveOptions.js.map +1 -1
- package/decorators/withScrolledInView/utils.d.ts +12 -1
- package/decorators/withScrolledInView/utils.js +7 -7
- package/decorators/withScrolledInView/utils.js.map +2 -2
- package/decorators/withScrolledInView/withScrolledInView.js +13 -35
- package/decorators/withScrolledInView/withScrolledInView.js.map +2 -2
- package/helpers/createApp.d.ts +2 -1
- package/helpers/createApp.js +2 -2
- package/helpers/createApp.js.map +2 -2
- package/helpers/getDirectChildren.js.map +1 -1
- package/helpers/importOnInteraction.js +4 -4
- package/helpers/importOnInteraction.js.map +2 -2
- package/helpers/importWhenVisible.js +2 -1
- package/helpers/importWhenVisible.js.map +2 -2
- package/package.json +2 -10
- package/services/drag.js +8 -8
- package/services/drag.js.map +2 -2
- package/services/index.d.ts +1 -1
- package/services/index.js.map +2 -2
- package/services/key.js +2 -2
- package/services/key.js.map +2 -2
- package/services/load.js +3 -0
- package/services/load.js.map +1 -1
- package/services/pointer.d.ts +1 -1
- package/services/pointer.js +7 -7
- package/services/pointer.js.map +2 -2
- package/services/raf.js +4 -6
- package/services/raf.js.map +2 -2
- package/services/resize.d.ts +7 -6
- package/services/resize.js +19 -26
- package/services/resize.js.map +2 -2
- package/services/scroll.js +8 -8
- package/services/scroll.js.map +2 -2
- package/services/service.js +2 -2
- package/services/service.js.map +2 -2
- package/utils/Queue.js +30 -0
- package/utils/Queue.js.map +1 -1
- package/utils/SmartQueue.d.ts +1 -1
- package/utils/SmartQueue.js +13 -1
- package/utils/SmartQueue.js.map +2 -2
- package/utils/collide/collidePointRect.js +4 -1
- package/utils/collide/collidePointRect.js.map +1 -1
- package/utils/collide/collideRectRect.js +4 -1
- package/utils/collide/collideRectRect.js.map +1 -1
- package/utils/css/animate.d.ts +33 -15
- package/utils/css/animate.js +80 -34
- package/utils/css/animate.js.map +2 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/classes.js.map +2 -2
- package/utils/css/getOffsetSizes.js +2 -2
- package/utils/css/getOffsetSizes.js.map +1 -1
- package/utils/css/index.d.ts +2 -1
- package/utils/css/index.js +4 -4
- package/utils/css/index.js.map +2 -2
- package/utils/css/matrix.d.ts +1 -1
- package/utils/css/matrix.js.map +2 -2
- package/utils/css/styles.js +2 -2
- package/utils/css/styles.js.map +2 -2
- package/utils/css/transform.d.ts +1 -1
- package/utils/css/transform.js +1 -1
- package/utils/css/transform.js.map +2 -2
- package/utils/css/transition.js +15 -0
- package/utils/css/transition.js.map +1 -1
- package/utils/css/utils.d.ts +1 -1
- package/utils/css/utils.js +1 -1
- package/utils/css/utils.js.map +2 -2
- package/utils/history.js +6 -5
- package/utils/history.js.map +2 -2
- package/utils/index.d.ts +5 -4
- package/utils/index.js +16 -16
- package/utils/index.js.map +2 -2
- package/utils/is.d.ts +12 -0
- package/utils/is.js +17 -0
- package/utils/is.js.map +2 -2
- package/utils/math/ease.d.ts +1 -0
- package/utils/math/ease.js +2 -0
- package/utils/math/ease.js.map +2 -2
- package/utils/math/index.d.ts +4 -3
- package/utils/math/index.js +5 -3
- package/utils/math/index.js.map +2 -2
- package/utils/math/mean.d.ts +1 -0
- package/utils/math/mean.js +17 -0
- package/utils/math/mean.js.map +7 -0
- package/utils/nextFrame.d.ts +4 -22
- package/utils/nextFrame.js +3 -10
- package/utils/nextFrame.js.map +2 -2
- package/utils/nextMicrotask.d.ts +4 -1
- package/utils/nextMicrotask.js +3 -3
- package/utils/nextMicrotask.js.map +2 -2
- package/utils/nextTick.d.ts +4 -1
- package/utils/nextTick.js +3 -3
- package/utils/nextTick.js.map +2 -2
- package/utils/random.d.ts +15 -0
- package/utils/random.js +15 -0
- package/utils/random.js.map +7 -0
- package/utils/scheduler.js +4 -4
- package/utils/scheduler.js.map +2 -2
- package/utils/scrollTo.d.ts +30 -6
- package/utils/scrollTo.js +97 -43
- package/utils/scrollTo.js.map +2 -2
- package/utils/string/endsWith.d.ts +8 -0
- package/utils/string/endsWith.js +13 -0
- package/utils/string/endsWith.js.map +7 -0
- package/utils/string/index.d.ts +2 -0
- package/utils/string/index.js +2 -0
- package/utils/string/index.js.map +2 -2
- package/utils/string/startsWith.d.ts +8 -0
- package/utils/string/startsWith.js +13 -0
- package/utils/string/startsWith.js.map +7 -0
- package/utils/string/withLeadingCharacters.js.map +1 -1
- package/utils/string/withTrailingCharacters.js.map +1 -1
- package/utils/string/withoutLeadingCharacters.js.map +1 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +1 -1
- package/utils/string/withoutTrailingCharacters.js.map +1 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +1 -1
- package/utils/{focusTrap.d.ts → trapFocus.d.ts} +2 -10
- package/utils/{focusTrap.js → trapFocus.js} +5 -9
- package/utils/trapFocus.js.map +7 -0
- package/utils/tween.d.ts +59 -10
- package/utils/tween.js +24 -18
- package/utils/tween.js.map +2 -2
- package/Base/Base.cjs +0 -325
- package/Base/Base.cjs.map +0 -7
- package/Base/features.cjs +0 -27
- package/Base/features.cjs.map +0 -7
- package/Base/index.cjs +0 -21
- package/Base/index.cjs.map +0 -7
- package/Base/managers/AbstractManager.cjs +0 -57
- package/Base/managers/AbstractManager.cjs.map +0 -7
- package/Base/managers/ChildrenManager.cjs +0 -123
- package/Base/managers/ChildrenManager.cjs.map +0 -7
- package/Base/managers/EventsManager.cjs +0 -220
- package/Base/managers/EventsManager.cjs.map +0 -7
- package/Base/managers/OptionsManager.cjs +0 -171
- package/Base/managers/OptionsManager.cjs.map +0 -7
- package/Base/managers/RefsManager.cjs +0 -104
- package/Base/managers/RefsManager.cjs.map +0 -7
- package/Base/managers/ResponsiveOptionsManager.cjs +0 -63
- package/Base/managers/ResponsiveOptionsManager.cjs.map +0 -7
- package/Base/managers/ServicesManager.cjs +0 -111
- package/Base/managers/ServicesManager.cjs.map +0 -7
- package/Base/managers/index.cjs +0 -39
- package/Base/managers/index.cjs.map +0 -7
- package/Base/types.cjs +0 -19
- package/Base/types.cjs.map +0 -7
- package/Base/utils.cjs +0 -91
- package/Base/utils.cjs.map +0 -7
- package/decorators/index.cjs +0 -33
- package/decorators/index.cjs.map +0 -7
- package/decorators/withBreakpointManager.cjs +0 -92
- package/decorators/withBreakpointManager.cjs.map +0 -7
- package/decorators/withBreakpointObserver.cjs +0 -118
- package/decorators/withBreakpointObserver.cjs.map +0 -7
- package/decorators/withDrag.cjs +0 -50
- package/decorators/withDrag.cjs.map +0 -7
- package/decorators/withExtraConfig.cjs +0 -43
- package/decorators/withExtraConfig.cjs.map +0 -7
- package/decorators/withFreezedOptions.cjs +0 -42
- package/decorators/withFreezedOptions.cjs.map +0 -7
- package/decorators/withIntersectionObserver.cjs +0 -62
- package/decorators/withIntersectionObserver.cjs.map +0 -7
- package/decorators/withMountOnMediaQuery.cjs +0 -70
- package/decorators/withMountOnMediaQuery.cjs.map +0 -7
- package/decorators/withMountWhenInView.cjs +0 -71
- package/decorators/withMountWhenInView.cjs.map +0 -7
- package/decorators/withMountWhenPrefersMotion.cjs +0 -30
- package/decorators/withMountWhenPrefersMotion.cjs.map +0 -7
- package/decorators/withRelativePointer.cjs +0 -50
- package/decorators/withRelativePointer.cjs.map +0 -7
- package/decorators/withResponsiveOptions.cjs +0 -38
- package/decorators/withResponsiveOptions.cjs.map +0 -7
- package/decorators/withScrolledInView/index.cjs +0 -22
- package/decorators/withScrolledInView/index.cjs.map +0 -7
- package/decorators/withScrolledInView/types.cjs +0 -19
- package/decorators/withScrolledInView/types.cjs.map +0 -7
- package/decorators/withScrolledInView/utils.cjs +0 -99
- package/decorators/withScrolledInView/utils.cjs.map +0 -7
- package/decorators/withScrolledInView/withScrolledInView.cjs +0 -216
- package/decorators/withScrolledInView/withScrolledInView.cjs.map +0 -7
- package/decorators/withVue2.cjs +0 -65
- package/decorators/withVue2.cjs.map +0 -7
- package/decorators/withVue2.d.ts +0 -16
- package/decorators/withVue2.js +0 -43
- package/decorators/withVue2.js.map +0 -7
- package/helpers/createApp.cjs +0 -58
- package/helpers/createApp.cjs.map +0 -7
- package/helpers/getClosestParent.cjs +0 -41
- package/helpers/getClosestParent.cjs.map +0 -7
- package/helpers/getDirectChildren.cjs +0 -47
- package/helpers/getDirectChildren.cjs.map +0 -7
- package/helpers/getInstanceFromElement.cjs +0 -32
- package/helpers/getInstanceFromElement.cjs.map +0 -7
- package/helpers/importOnInteraction.cjs +0 -48
- package/helpers/importOnInteraction.cjs.map +0 -7
- package/helpers/importOnMediaQuery.cjs +0 -44
- package/helpers/importOnMediaQuery.cjs.map +0 -7
- package/helpers/importWhenIdle.cjs +0 -46
- package/helpers/importWhenIdle.cjs.map +0 -7
- package/helpers/importWhenPrefersMotion.cjs +0 -36
- package/helpers/importWhenPrefersMotion.cjs.map +0 -7
- package/helpers/importWhenVisible.cjs +0 -43
- package/helpers/importWhenVisible.cjs.map +0 -7
- package/helpers/index.cjs +0 -49
- package/helpers/index.cjs.map +0 -7
- package/helpers/utils.cjs +0 -37
- package/helpers/utils.cjs.map +0 -7
- package/index.cjs +0 -31
- package/index.cjs.map +0 -7
- package/services/drag.cjs +0 -227
- package/services/drag.cjs.map +0 -7
- package/services/index.cjs +0 -47
- package/services/index.cjs.map +0 -7
- package/services/key.cjs +0 -93
- package/services/key.cjs.map +0 -7
- package/services/load.cjs +0 -57
- package/services/load.cjs.map +0 -7
- package/services/pointer.cjs +0 -145
- package/services/pointer.cjs.map +0 -7
- package/services/raf.cjs +0 -80
- package/services/raf.cjs.map +0 -7
- package/services/resize.cjs +0 -103
- package/services/resize.cjs.map +0 -7
- package/services/scroll.cjs +0 -115
- package/services/scroll.cjs.map +0 -7
- package/services/service.cjs +0 -69
- package/services/service.cjs.map +0 -7
- package/utils/Queue.cjs +0 -63
- package/utils/Queue.cjs.map +0 -7
- package/utils/SmartQueue.cjs +0 -57
- package/utils/SmartQueue.cjs.map +0 -7
- package/utils/collide/boundingRectToCircle.cjs +0 -36
- package/utils/collide/boundingRectToCircle.cjs.map +0 -7
- package/utils/collide/collideCircleCircle.cjs +0 -35
- package/utils/collide/collideCircleCircle.cjs.map +0 -7
- package/utils/collide/collideCircleRect.cjs +0 -47
- package/utils/collide/collideCircleRect.cjs.map +0 -7
- package/utils/collide/collidePointCircle.cjs +0 -32
- package/utils/collide/collidePointCircle.cjs.map +0 -7
- package/utils/collide/collidePointRect.cjs +0 -29
- package/utils/collide/collidePointRect.cjs.map +0 -7
- package/utils/collide/collideRectRect.cjs +0 -29
- package/utils/collide/collideRectRect.cjs.map +0 -7
- package/utils/collide/index.cjs +0 -43
- package/utils/collide/index.cjs.map +0 -7
- package/utils/css/animate.cjs +0 -193
- package/utils/css/animate.cjs.map +0 -7
- package/utils/css/classes.cjs +0 -52
- package/utils/css/classes.cjs.map +0 -7
- package/utils/css/getOffsetSizes.cjs +0 -48
- package/utils/css/getOffsetSizes.cjs.map +0 -7
- package/utils/css/index.cjs +0 -48
- package/utils/css/index.cjs.map +0 -7
- package/utils/css/matrix.cjs +0 -30
- package/utils/css/matrix.cjs.map +0 -7
- package/utils/css/styles.cjs +0 -45
- package/utils/css/styles.cjs.map +0 -7
- package/utils/css/transform.cjs +0 -91
- package/utils/css/transform.cjs.map +0 -7
- package/utils/css/transition.cjs +0 -126
- package/utils/css/transition.cjs.map +0 -7
- package/utils/css/utils.cjs +0 -32
- package/utils/css/utils.cjs.map +0 -7
- package/utils/debounce.cjs +0 -35
- package/utils/debounce.cjs.map +0 -7
- package/utils/dom/ancestors.cjs +0 -37
- package/utils/dom/ancestors.cjs.map +0 -7
- package/utils/dom/index.cjs +0 -21
- package/utils/dom/index.cjs.map +0 -7
- package/utils/focusTrap.cjs +0 -89
- package/utils/focusTrap.cjs.map +0 -7
- package/utils/focusTrap.js.map +0 -7
- package/utils/getComponentResolver.cjs +0 -38
- package/utils/getComponentResolver.cjs.map +0 -7
- package/utils/has.cjs +0 -29
- package/utils/has.cjs.map +0 -7
- package/utils/history.cjs +0 -91
- package/utils/history.cjs.map +0 -7
- package/utils/index.cjs +0 -72
- package/utils/index.cjs.map +0 -7
- package/utils/is.cjs +0 -41
- package/utils/is.cjs.map +0 -7
- package/utils/keyCodes.cjs +0 -36
- package/utils/keyCodes.cjs.map +0 -7
- package/utils/math/clamp.cjs +0 -29
- package/utils/math/clamp.cjs.map +0 -7
- package/utils/math/clamp01.cjs +0 -36
- package/utils/math/clamp01.cjs.map +0 -7
- package/utils/math/createEases.cjs +0 -33
- package/utils/math/createEases.cjs.map +0 -7
- package/utils/math/damp.cjs +0 -29
- package/utils/math/damp.cjs.map +0 -7
- package/utils/math/ease.cjs +0 -82
- package/utils/math/ease.cjs.map +0 -7
- package/utils/math/index.cjs +0 -50
- package/utils/math/index.cjs.map +0 -7
- package/utils/math/inertiaFinalValue.cjs +0 -43
- package/utils/math/inertiaFinalValue.cjs.map +0 -7
- package/utils/math/lerp.cjs +0 -29
- package/utils/math/lerp.cjs.map +0 -7
- package/utils/math/map.cjs +0 -29
- package/utils/math/map.cjs.map +0 -7
- package/utils/math/round.cjs +0 -29
- package/utils/math/round.cjs.map +0 -7
- package/utils/memoize.cjs +0 -48
- package/utils/memoize.cjs.map +0 -7
- package/utils/nextFrame.cjs +0 -41
- package/utils/nextFrame.cjs.map +0 -7
- package/utils/nextMicrotask.cjs +0 -30
- package/utils/nextMicrotask.cjs.map +0 -7
- package/utils/nextTick.cjs +0 -31
- package/utils/nextTick.cjs.map +0 -7
- package/utils/noop.cjs +0 -32
- package/utils/noop.cjs.map +0 -7
- package/utils/object/autoBind.cjs +0 -54
- package/utils/object/autoBind.cjs.map +0 -7
- package/utils/object/autoBind.d.ts +0 -14
- package/utils/object/autoBind.js +0 -26
- package/utils/object/autoBind.js.map +0 -7
- package/utils/object/getAllProperties.cjs +0 -39
- package/utils/object/getAllProperties.cjs.map +0 -7
- package/utils/object/index.cjs +0 -35
- package/utils/object/index.cjs.map +0 -7
- package/utils/object/index.d.ts +0 -2
- package/utils/object/index.js +0 -7
- package/utils/object/index.js.map +0 -7
- package/utils/scheduler.cjs +0 -75
- package/utils/scheduler.cjs.map +0 -7
- package/utils/scrollTo.cjs +0 -84
- package/utils/scrollTo.cjs.map +0 -7
- package/utils/string/index.cjs +0 -51
- package/utils/string/index.cjs.map +0 -7
- package/utils/string/withLeadingCharacters.cjs +0 -36
- package/utils/string/withLeadingCharacters.cjs.map +0 -7
- package/utils/string/withLeadingSlash.cjs +0 -36
- package/utils/string/withLeadingSlash.cjs.map +0 -7
- package/utils/string/withTrailingCharacters.cjs +0 -36
- package/utils/string/withTrailingCharacters.cjs.map +0 -7
- package/utils/string/withTrailingSlash.cjs +0 -36
- package/utils/string/withTrailingSlash.cjs.map +0 -7
- package/utils/string/withoutLeadingCharacters.cjs +0 -29
- package/utils/string/withoutLeadingCharacters.cjs.map +0 -7
- package/utils/string/withoutLeadingCharactersRecursive.cjs +0 -41
- package/utils/string/withoutLeadingCharactersRecursive.cjs.map +0 -7
- package/utils/string/withoutLeadingSlash.cjs +0 -36
- package/utils/string/withoutLeadingSlash.cjs.map +0 -7
- package/utils/string/withoutTrailingCharacters.cjs +0 -29
- package/utils/string/withoutTrailingCharacters.cjs.map +0 -7
- package/utils/string/withoutTrailingCharactersRecursive.cjs +0 -41
- package/utils/string/withoutTrailingCharactersRecursive.cjs.map +0 -7
- package/utils/string/withoutTrailingSlash.cjs +0 -36
- package/utils/string/withoutTrailingSlash.cjs.map +0 -7
- package/utils/throttle.cjs +0 -37
- package/utils/throttle.cjs.map +0 -7
- package/utils/tween.cjs +0 -118
- package/utils/tween.cjs.map +0 -7
- package/utils/wait.cjs +0 -31
- package/utils/wait.cjs.map +0 -7
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts"],
|
|
4
4
|
"sourcesContent": ["import withoutLeadingCharacters from './withoutLeadingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the start.\n * @returns {string}\n */\nexport default function withoutLeadingCharactersRecursive(\n string: string,\n characters: string,\n): string {\n let str = withoutLeadingCharacters(string, characters);\n const regex = new RegExp(`^${characters}`);\n\n while (regex.test(str)) {\n str = withoutLeadingCharacters(str, characters);\n }\n\n return str;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,8BAA8B;AAStB,SAAR,kCACL,QACA,YACQ;AACR,MAAI,MAAM,yBAAyB,QAAQ,UAAU;AACrD,QAAM,QAAQ,IAAI,OAAO,IAAI,
|
|
5
|
+
"mappings": "AAAA,OAAO,8BAA8B;AAStB,SAAR,kCACL,QACA,YACQ;AACR,MAAI,MAAM,yBAAyB,QAAQ,UAAU;AACrD,QAAM,QAAQ,IAAI,OAAO,IAAI,UAAU,EAAE;AAEzC,SAAO,MAAM,KAAK,GAAG,GAAG;AACtB,UAAM,yBAAyB,KAAK,UAAU;AAAA,EAChD;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutTrailingCharacters.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Remove the given characters from the end of the given string.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to remove from the end.\n * @returns {string}\n */\nexport default function withoutTrailingCharacters(string: string, characters: string): string {\n return string.replace(new RegExp(`${characters}$`), '');\n}\n"],
|
|
5
|
-
"mappings": "AAOe,SAAR,0BAA2C,QAAgB,YAA4B;AAC5F,SAAO,OAAO,QAAQ,IAAI,OAAO,GAAG,
|
|
5
|
+
"mappings": "AAOe,SAAR,0BAA2C,QAAgB,YAA4B;AAC5F,SAAO,OAAO,QAAQ,IAAI,OAAO,GAAG,UAAU,GAAG,GAAG,EAAE;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts"],
|
|
4
4
|
"sourcesContent": ["import withoutTrailingCharacters from './withoutTrailingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the start.\n * @returns {string}\n */\nexport default function withoutTrailingCharactersRecursive(\n string: string,\n characters: string,\n): string {\n let str = withoutTrailingCharacters(string, characters);\n const regex = new RegExp(`${characters}$`);\n\n while (regex.test(str)) {\n str = withoutTrailingCharacters(str, characters);\n }\n\n return str;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,+BAA+B;AASvB,SAAR,mCACL,QACA,YACQ;AACR,MAAI,MAAM,0BAA0B,QAAQ,UAAU;AACtD,QAAM,QAAQ,IAAI,OAAO,GAAG,
|
|
5
|
+
"mappings": "AAAA,OAAO,+BAA+B;AASvB,SAAR,mCACL,QACA,YACQ;AACR,MAAI,MAAM,0BAA0B,QAAQ,UAAU;AACtD,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,GAAG;AAEzC,SAAO,MAAM,KAAK,GAAG,GAAG;AACtB,UAAM,0BAA0B,KAAK,UAAU;AAAA,EACjD;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,16 +8,8 @@ export declare function saveActiveElement(): void;
|
|
|
8
8
|
* @param {HTMLElement} element The element in which to trap the tabulations.
|
|
9
9
|
* @param {KeyboardEvent} event The keydown or keyup event.
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function trapFocus(element: HTMLElement, event: KeyboardEvent): void;
|
|
12
12
|
/**
|
|
13
13
|
* Untrap the tab navigation.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
16
|
-
/**
|
|
17
|
-
* Use a trap/untrap tabs logic.
|
|
18
|
-
*/
|
|
19
|
-
export default function useFocusTrap(): {
|
|
20
|
-
trap: typeof trap;
|
|
21
|
-
untrap: typeof untrap;
|
|
22
|
-
saveActiveElement: typeof saveActiveElement;
|
|
23
|
-
};
|
|
15
|
+
export declare function untrapFocus(): void;
|
|
@@ -17,7 +17,7 @@ let focusedBefore;
|
|
|
17
17
|
function saveActiveElement() {
|
|
18
18
|
focusedBefore = document.activeElement;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function trapFocus(element, event) {
|
|
21
21
|
if (event.keyCode !== keyCodes.TAB) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -43,19 +43,15 @@ function trap(element, event) {
|
|
|
43
43
|
event.preventDefault();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function untrapFocus() {
|
|
47
47
|
if (focusedBefore && isFunction(focusedBefore.focus)) {
|
|
48
48
|
focusedBefore.focus();
|
|
49
49
|
focusedBefore = null;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function useFocusTrap() {
|
|
53
|
-
return { trap, untrap, saveActiveElement };
|
|
54
|
-
}
|
|
55
52
|
export {
|
|
56
|
-
useFocusTrap as default,
|
|
57
53
|
saveActiveElement,
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
trapFocus,
|
|
55
|
+
untrapFocus
|
|
60
56
|
};
|
|
61
|
-
//# sourceMappingURL=
|
|
57
|
+
//# sourceMappingURL=trapFocus.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/js-toolkit/utils/trapFocus.ts"],
|
|
4
|
+
"sourcesContent": ["import keyCodes from './keyCodes.js';\nimport { isFunction } from './is.js';\n\nconst FOCUSABLE_ELEMENTS = [\n 'a[href]:not([tabindex^=\"-\"]):not([inert])',\n 'area[href]:not([tabindex^=\"-\"]):not([inert])',\n 'input:not([disabled]):not([inert])',\n 'select:not([disabled]):not([inert])',\n 'textarea:not([disabled]):not([inert])',\n 'button:not([disabled]):not([inert])',\n 'iframe:not([tabindex^=\"-\"]):not([inert])',\n 'audio:not([tabindex^=\"-\"]):not([inert])',\n 'video:not([tabindex^=\"-\"]):not([inert])',\n '[contenteditable]:not([tabindex^=\"-\"]):not([inert])',\n '[tabindex]:not([tabindex^=\"-\"]):not([inert])',\n];\n\nlet focusedBefore;\n\n/**\n * Save the current active element.\n */\nexport function saveActiveElement() {\n focusedBefore = document.activeElement;\n}\n\n/**\n * Trap tab navigation inside the given element.\n *\n * @param {HTMLElement} element The element in which to trap the tabulations.\n * @param {KeyboardEvent} event The keydown or keyup event.\n */\nexport function trapFocus(element: HTMLElement, event: KeyboardEvent) {\n if (event.keyCode !== keyCodes.TAB) {\n return;\n }\n\n // Save the previous focused element\n if (!focusedBefore) {\n focusedBefore = document.activeElement;\n }\n\n const focusableChildren: HTMLElement[] = Array.from(\n element.querySelectorAll(FOCUSABLE_ELEMENTS.join(', ')),\n ) as HTMLElement[];\n const focusedItemIndex =\n document.activeElement instanceof HTMLElement\n ? focusableChildren.indexOf(document.activeElement)\n : -1;\n\n if (!focusableChildren.length) {\n return;\n }\n\n if (focusedItemIndex < 0) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is being pressed while tabbing (moving backwards) and\n // the currently focused item is the first one, move the focus to the last\n // focusable item from the dialog element\n if (event.shiftKey && focusedItemIndex === 0) {\n focusableChildren.at(-1).focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is not being pressed (moving forwards) and the currently\n // focused item is the last one, move the focus to the first focusable item\n // from the dialog element\n else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n}\n\n/**\n * Untrap the tab navigation.\n */\nexport function untrapFocus() {\n if (focusedBefore && isFunction(focusedBefore.focus)) {\n focusedBefore.focus();\n focusedBefore = null;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,cAAc;AACrB,SAAS,kBAAkB;AAE3B,MAAM,qBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAI;AAKG,SAAS,oBAAoB;AAClC,kBAAgB,SAAS;AAC3B;AAQO,SAAS,UAAU,SAAsB,OAAsB;AACpE,MAAI,MAAM,YAAY,SAAS,KAAK;AAClC;AAAA,EACF;AAGA,MAAI,CAAC,eAAe;AAClB,oBAAgB,SAAS;AAAA,EAC3B;AAEA,QAAM,oBAAmC,MAAM;AAAA,IAC7C,QAAQ,iBAAiB,mBAAmB,KAAK,IAAI,CAAC;AAAA,EACxD;AACA,QAAM,mBACJ,SAAS,yBAAyB,cAC9B,kBAAkB,QAAQ,SAAS,aAAa,IAChD;AAEN,MAAI,CAAC,kBAAkB,QAAQ;AAC7B;AAAA,EACF;AAEA,MAAI,mBAAmB,GAAG;AACxB,sBAAkB,CAAC,EAAE,MAAM;AAC3B,UAAM,eAAe;AAAA,EACvB;AAKA,MAAI,MAAM,YAAY,qBAAqB,GAAG;AAC5C,sBAAkB,GAAG,EAAE,EAAE,MAAM;AAC/B,UAAM,eAAe;AAAA,EACvB,WAKS,CAAC,MAAM,YAAY,qBAAqB,kBAAkB,SAAS,GAAG;AAC7E,sBAAkB,CAAC,EAAE,MAAM;AAC3B,UAAM,eAAe;AAAA,EACvB;AACF;AAKO,SAAS,cAAc;AAC5B,MAAI,iBAAiB,WAAW,cAAc,KAAK,GAAG;AACpD,kBAAc,MAAM;AACpB,oBAAgB;AAAA,EAClB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/utils/tween.d.ts
CHANGED
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import type { EasingFunction } from './math/createEases.js';
|
|
2
2
|
export type BezierCurve = [number, number, number, number];
|
|
3
|
+
/**
|
|
4
|
+
* Controls for a tween.
|
|
5
|
+
*/
|
|
6
|
+
export interface Tween {
|
|
7
|
+
/**
|
|
8
|
+
* Start the tween from the beginning.
|
|
9
|
+
*/
|
|
10
|
+
start: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Finish the tween and set its state to the end.
|
|
13
|
+
*/
|
|
14
|
+
finish: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Pause the tween.
|
|
17
|
+
*/
|
|
18
|
+
pause: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Start the tween from the current paused progress.
|
|
21
|
+
*/
|
|
22
|
+
play: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Set and get the tween's progress.
|
|
25
|
+
*/
|
|
26
|
+
progress: (progress?: number) => number;
|
|
27
|
+
}
|
|
3
28
|
export interface TweenOptions {
|
|
29
|
+
/**
|
|
30
|
+
* The duration, in seconds.
|
|
31
|
+
* Defaults to `1`.
|
|
32
|
+
*/
|
|
4
33
|
duration?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The delay, in seconds.
|
|
36
|
+
* Defaults to `0`.
|
|
37
|
+
*/
|
|
38
|
+
delay?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The easing function or bezier curve to use.
|
|
41
|
+
* Defaults to a linear easing function.
|
|
42
|
+
*/
|
|
5
43
|
easing?: EasingFunction | BezierCurve;
|
|
44
|
+
/**
|
|
45
|
+
* The smooth factor. Setting this option to `true` or a `number` will disable the `duration` option.
|
|
46
|
+
*/
|
|
47
|
+
smooth?: true | number;
|
|
48
|
+
/**
|
|
49
|
+
* The precision for when to consider the tween finished.
|
|
50
|
+
* Defaults to `0.0001`.
|
|
51
|
+
*/
|
|
6
52
|
precision?: number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
53
|
+
/**
|
|
54
|
+
* A callback executed on start.
|
|
55
|
+
*/
|
|
56
|
+
onStart?: (progress: number) => void;
|
|
57
|
+
/**
|
|
58
|
+
* A callback executed each time the progress is updated.
|
|
59
|
+
*/
|
|
60
|
+
onProgress?: (progress: number) => void;
|
|
61
|
+
/**
|
|
62
|
+
* A callback executed when the tween is finished.
|
|
63
|
+
*/
|
|
64
|
+
onFinish?: (progress: number) => void;
|
|
10
65
|
}
|
|
11
66
|
/**
|
|
12
67
|
* Normalize a easing function with default fallbacks.
|
|
@@ -15,10 +70,4 @@ export declare function normalizeEase(ease: EasingFunction | BezierCurve): Easin
|
|
|
15
70
|
/**
|
|
16
71
|
* Tween from 0 to 1.
|
|
17
72
|
*/
|
|
18
|
-
export declare function tween(callback: (progress: number) => unknown, options?: TweenOptions):
|
|
19
|
-
start: () => void;
|
|
20
|
-
finish: () => number;
|
|
21
|
-
pause: () => void;
|
|
22
|
-
play: () => void;
|
|
23
|
-
progress: (newProgress: number) => number;
|
|
24
|
-
};
|
|
73
|
+
export declare function tween(callback: (progress: number) => unknown, options?: TweenOptions): Tween;
|
package/utils/tween.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cubicBezier } from "@motionone/easing";
|
|
2
|
-
import { lerp, map, clamp01 } from "./math/index.js";
|
|
3
|
-
import { isDefined, isArray } from "./is.js";
|
|
2
|
+
import { lerp, map, clamp01, damp, inertiaFinalValue } from "./math/index.js";
|
|
3
|
+
import { isDefined, isArray, isNumber } from "./is.js";
|
|
4
4
|
import { noop, noopValue as linear } from "./noop.js";
|
|
5
5
|
import useRaf from "../services/raf.js";
|
|
6
6
|
let id = 0;
|
|
@@ -18,12 +18,16 @@ function tween(callback, options = {}) {
|
|
|
18
18
|
const raf = useRaf();
|
|
19
19
|
let progressValue = 0;
|
|
20
20
|
let easedProgress = 0;
|
|
21
|
+
const isSmooth = isDefined(options.smooth) && (isNumber(options.smooth) || options.smooth);
|
|
22
|
+
const smoothFactor = isNumber(options.smooth) ? options.smooth : 0.1;
|
|
21
23
|
const precision = options.precision ?? DEFAULT_PROGRESS_PRECISION;
|
|
22
24
|
const ease = normalizeEase(options.easing);
|
|
25
|
+
let delay = options.delay ?? 0;
|
|
26
|
+
delay *= 1e3;
|
|
23
27
|
let duration = options.duration ?? 1;
|
|
24
28
|
duration *= 1e3;
|
|
25
|
-
let startTime =
|
|
26
|
-
let endTime = startTime
|
|
29
|
+
let startTime = getStartTime();
|
|
30
|
+
let endTime = getEndTime(startTime);
|
|
27
31
|
const key = `tw-${id}`;
|
|
28
32
|
id += 1;
|
|
29
33
|
const { onStart = noop, onProgress = noop, onFinish = noop } = options;
|
|
@@ -33,34 +37,36 @@ function tween(callback, options = {}) {
|
|
|
33
37
|
raf.remove(key);
|
|
34
38
|
}
|
|
35
39
|
function progress(newProgress) {
|
|
36
|
-
if (
|
|
40
|
+
if (!isDefined(newProgress)) {
|
|
37
41
|
return easedProgress;
|
|
38
42
|
}
|
|
39
43
|
progressValue = newProgress;
|
|
40
|
-
easedProgress = ease(progressValue);
|
|
44
|
+
easedProgress = isSmooth ? damp(progressValue, easedProgress, smoothFactor, precision) : ease(progressValue);
|
|
41
45
|
if (Math.abs(1 - easedProgress) < precision) {
|
|
42
46
|
progressValue = 1;
|
|
43
47
|
easedProgress = 1;
|
|
44
48
|
}
|
|
45
49
|
callback(easedProgress);
|
|
46
|
-
onProgress(
|
|
50
|
+
onProgress(easedProgress);
|
|
47
51
|
if (easedProgress === 1) {
|
|
48
52
|
pause();
|
|
49
|
-
requestAnimationFrame(() => onFinish(
|
|
53
|
+
requestAnimationFrame(() => onFinish(easedProgress));
|
|
50
54
|
}
|
|
51
|
-
return
|
|
55
|
+
return easedProgress;
|
|
52
56
|
}
|
|
53
57
|
function tick(props) {
|
|
54
|
-
if (!isRunning) {
|
|
55
|
-
raf.remove(key);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
58
|
progress(clamp01(map(props.time, startTime, endTime, 0, 1)));
|
|
59
59
|
}
|
|
60
|
+
function getStartTime() {
|
|
61
|
+
return performance.now() + delay;
|
|
62
|
+
}
|
|
63
|
+
function getEndTime(time) {
|
|
64
|
+
return isSmooth ? inertiaFinalValue(time, 1) : time + duration;
|
|
65
|
+
}
|
|
60
66
|
function start() {
|
|
61
|
-
onStart();
|
|
62
|
-
startTime =
|
|
63
|
-
endTime = startTime
|
|
67
|
+
onStart(0);
|
|
68
|
+
startTime = getStartTime();
|
|
69
|
+
endTime = getEndTime(startTime);
|
|
64
70
|
progressValue = 0;
|
|
65
71
|
easedProgress = 0;
|
|
66
72
|
isRunning = true;
|
|
@@ -70,8 +76,8 @@ function tween(callback, options = {}) {
|
|
|
70
76
|
if (isRunning) {
|
|
71
77
|
return;
|
|
72
78
|
}
|
|
73
|
-
startTime =
|
|
74
|
-
endTime = startTime
|
|
79
|
+
startTime = getStartTime() - lerp(0, duration, progressValue);
|
|
80
|
+
endTime = getEndTime(startTime);
|
|
75
81
|
isRunning = true;
|
|
76
82
|
raf.add(key, tick);
|
|
77
83
|
}
|
package/utils/tween.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/tween.ts"],
|
|
4
|
-
"sourcesContent": ["import { cubicBezier } from '@motionone/easing';\nimport { lerp, map, clamp01 } from './math/index.js';\nimport { isDefined, isArray } from './is.js';\nimport { noop, noopValue as linear } from './noop.js';\nimport useRaf from '../services/raf.js';\nimport type { EasingFunction } from './math/createEases.js';\n\nlet id = 0;\nconst DEFAULT_PROGRESS_PRECISION = 0.0001;\n\nexport type BezierCurve = [number, number, number, number];\n\nexport interface TweenOptions {\n duration?: number;\n easing?: EasingFunction | BezierCurve;\n precision?: number;\n onStart?: () => void;\n onProgress?: (progress: number
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,MAAM,KAAK,
|
|
4
|
+
"sourcesContent": ["import { cubicBezier } from '@motionone/easing';\nimport { lerp, map, clamp01, damp, inertiaFinalValue } from './math/index.js';\nimport { isDefined, isArray, isNumber } from './is.js';\nimport { noop, noopValue as linear } from './noop.js';\nimport useRaf from '../services/raf.js';\nimport type { EasingFunction } from './math/createEases.js';\n\nlet id = 0;\nconst DEFAULT_PROGRESS_PRECISION = 0.0001;\n\nexport type BezierCurve = [number, number, number, number];\n\n/**\n * Controls for a tween.\n */\nexport interface Tween {\n /**\n * Start the tween from the beginning.\n */\n start: () => void;\n /**\n * Finish the tween and set its state to the end.\n */\n finish: () => void;\n /**\n * Pause the tween.\n */\n pause: () => void;\n /**\n * Start the tween from the current paused progress.\n */\n play: () => void;\n /**\n * Set and get the tween's progress.\n */\n progress: (progress?: number) => number;\n}\n\nexport interface TweenOptions {\n /**\n * The duration, in seconds.\n * Defaults to `1`.\n */\n duration?: number;\n /**\n * The delay, in seconds.\n * Defaults to `0`.\n */\n delay?: number;\n /**\n * The easing function or bezier curve to use.\n * Defaults to a linear easing function.\n */\n easing?: EasingFunction | BezierCurve;\n /**\n * The smooth factor. Setting this option to `true` or a `number` will disable the `duration` option.\n */\n smooth?: true | number;\n /**\n * The precision for when to consider the tween finished.\n * Defaults to `0.0001`.\n */\n precision?: number;\n /**\n * A callback executed on start.\n */\n onStart?: (progress: number) => void;\n /**\n * A callback executed each time the progress is updated.\n */\n onProgress?: (progress: number) => void;\n /**\n * A callback executed when the tween is finished.\n */\n onFinish?: (progress: number) => void;\n}\n\n/**\n * Normalize a easing function with default fallbacks.\n */\nexport function normalizeEase(ease: EasingFunction | BezierCurve): EasingFunction {\n if (!isDefined(ease)) {\n return linear;\n }\n\n if (isArray(ease)) {\n return cubicBezier(...ease);\n }\n\n return ease;\n}\n\n/**\n * Tween from 0 to 1.\n */\nexport function tween(callback: (progress: number) => unknown, options: TweenOptions = {}): Tween {\n const raf = useRaf();\n\n let progressValue = 0;\n let easedProgress = 0;\n\n const isSmooth = isDefined(options.smooth) && (isNumber(options.smooth) || options.smooth);\n const smoothFactor = isNumber(options.smooth) ? options.smooth : 0.1;\n const precision = options.precision ?? DEFAULT_PROGRESS_PRECISION;\n const ease = normalizeEase(options.easing);\n\n let delay = options.delay ?? 0;\n delay *= 1000;\n let duration = options.duration ?? 1;\n duration *= 1000;\n\n /* eslint-disable @typescript-eslint/no-use-before-define */\n let startTime = getStartTime();\n let endTime = getEndTime(startTime);\n /* eslint-enable @typescript-eslint/no-use-before-define */\n\n const key = `tw-${id}`;\n id += 1;\n\n const { onStart = noop, onProgress = noop, onFinish = noop } = options;\n let isRunning = false;\n\n /**\n * Pause the animation.\n */\n function pause() {\n isRunning = false;\n raf.remove(key);\n }\n\n /**\n * Set the progress value.\n */\n function progress(newProgress: number) {\n if (!isDefined(newProgress)) {\n return easedProgress;\n }\n\n progressValue = newProgress;\n easedProgress = isSmooth\n ? damp(progressValue, easedProgress, smoothFactor, precision)\n : ease(progressValue);\n\n // Stop when reaching precision\n if (Math.abs(1 - easedProgress) < precision) {\n progressValue = 1;\n easedProgress = 1;\n }\n\n callback(easedProgress);\n onProgress(easedProgress);\n\n if (easedProgress === 1) {\n pause();\n requestAnimationFrame(() => onFinish(easedProgress));\n }\n\n return easedProgress;\n }\n\n /**\n * Loop for rendering the animation.\n */\n function tick(props: { time: number }) {\n progress(clamp01(map(props.time, startTime, endTime, 0, 1)));\n }\n\n function getStartTime() {\n return performance.now() + delay;\n }\n\n function getEndTime(time: number) {\n return isSmooth ? inertiaFinalValue(time, 1) : time + duration;\n }\n\n /**\n * Play the animation.\n */\n function start() {\n onStart(0);\n startTime = getStartTime();\n endTime = getEndTime(startTime);\n progressValue = 0;\n easedProgress = 0;\n isRunning = true;\n\n raf.add(key, tick);\n }\n\n /**\n * Play a paused animation.\n */\n function play() {\n if (isRunning) {\n return;\n }\n\n startTime = getStartTime() - lerp(0, duration, progressValue);\n endTime = getEndTime(startTime);\n isRunning = true;\n\n raf.add(key, tick);\n }\n\n return {\n start,\n finish: () => progress(1),\n pause,\n play,\n progress,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,MAAM,KAAK,SAAS,MAAM,yBAAyB;AAC5D,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,MAAM,aAAa,cAAc;AAC1C,OAAO,YAAY;AAGnB,IAAI,KAAK;AACT,MAAM,6BAA6B;AAwE5B,SAAS,cAAc,MAAoD;AAChF,MAAI,CAAC,UAAU,IAAI,GAAG;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,GAAG;AACjB,WAAO,YAAY,GAAG,IAAI;AAAA,EAC5B;AAEA,SAAO;AACT;AAKO,SAAS,MAAM,UAAyC,UAAwB,CAAC,GAAU;AAChG,QAAM,MAAM,OAAO;AAEnB,MAAI,gBAAgB;AACpB,MAAI,gBAAgB;AAEpB,QAAM,WAAW,UAAU,QAAQ,MAAM,MAAM,SAAS,QAAQ,MAAM,KAAK,QAAQ;AACnF,QAAM,eAAe,SAAS,QAAQ,MAAM,IAAI,QAAQ,SAAS;AACjE,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,OAAO,cAAc,QAAQ,MAAM;AAEzC,MAAI,QAAQ,QAAQ,SAAS;AAC7B,WAAS;AACT,MAAI,WAAW,QAAQ,YAAY;AACnC,cAAY;AAGZ,MAAI,YAAY,aAAa;AAC7B,MAAI,UAAU,WAAW,SAAS;AAGlC,QAAM,MAAM,MAAM,EAAE;AACpB,QAAM;AAEN,QAAM,EAAE,UAAU,MAAM,aAAa,MAAM,WAAW,KAAK,IAAI;AAC/D,MAAI,YAAY;AAKhB,WAAS,QAAQ;AACf,gBAAY;AACZ,QAAI,OAAO,GAAG;AAAA,EAChB;AAKA,WAAS,SAAS,aAAqB;AACrC,QAAI,CAAC,UAAU,WAAW,GAAG;AAC3B,aAAO;AAAA,IACT;AAEA,oBAAgB;AAChB,oBAAgB,WACZ,KAAK,eAAe,eAAe,cAAc,SAAS,IAC1D,KAAK,aAAa;AAGtB,QAAI,KAAK,IAAI,IAAI,aAAa,IAAI,WAAW;AAC3C,sBAAgB;AAChB,sBAAgB;AAAA,IAClB;AAEA,aAAS,aAAa;AACtB,eAAW,aAAa;AAExB,QAAI,kBAAkB,GAAG;AACvB,YAAM;AACN,4BAAsB,MAAM,SAAS,aAAa,CAAC;AAAA,IACrD;AAEA,WAAO;AAAA,EACT;AAKA,WAAS,KAAK,OAAyB;AACrC,aAAS,QAAQ,IAAI,MAAM,MAAM,WAAW,SAAS,GAAG,CAAC,CAAC,CAAC;AAAA,EAC7D;AAEA,WAAS,eAAe;AACtB,WAAO,YAAY,IAAI,IAAI;AAAA,EAC7B;AAEA,WAAS,WAAW,MAAc;AAChC,WAAO,WAAW,kBAAkB,MAAM,CAAC,IAAI,OAAO;AAAA,EACxD;AAKA,WAAS,QAAQ;AACf,YAAQ,CAAC;AACT,gBAAY,aAAa;AACzB,cAAU,WAAW,SAAS;AAC9B,oBAAgB;AAChB,oBAAgB;AAChB,gBAAY;AAEZ,QAAI,IAAI,KAAK,IAAI;AAAA,EACnB;AAKA,WAAS,OAAO;AACd,QAAI,WAAW;AACb;AAAA,IACF;AAEA,gBAAY,aAAa,IAAI,KAAK,GAAG,UAAU,aAAa;AAC5D,cAAU,WAAW,SAAS;AAC9B,gBAAY;AAEZ,QAAI,IAAI,KAAK,IAAI;AAAA,EACnB;AAEA,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,MAAM,SAAS,CAAC;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Base/Base.cjs
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __publicField = (obj, key, value) => {
|
|
20
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/js-toolkit/Base/Base.ts
|
|
25
|
-
var Base_exports = {};
|
|
26
|
-
__export(Base_exports, {
|
|
27
|
-
Base: () => Base
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(Base_exports);
|
|
30
|
-
var import_utils = require("./utils.cjs");
|
|
31
|
-
var import_managers = require("./managers/index.cjs");
|
|
32
|
-
var import_utils2 = require("../utils/index.cjs");
|
|
33
|
-
var id = 0;
|
|
34
|
-
function createAndTestManagers(instance) {
|
|
35
|
-
[
|
|
36
|
-
{
|
|
37
|
-
prop: "__options",
|
|
38
|
-
constructorName: "OptionsManager",
|
|
39
|
-
constructor: import_managers.OptionsManager
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
prop: "__services",
|
|
43
|
-
constructorName: "ServicesManager",
|
|
44
|
-
constructor: import_managers.ServicesManager
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
prop: "__events",
|
|
48
|
-
constructorName: "EventsManager",
|
|
49
|
-
constructor: import_managers.EventsManager
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
prop: "__refs",
|
|
53
|
-
constructorName: "RefsManager",
|
|
54
|
-
constructor: import_managers.RefsManager
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
prop: "__children",
|
|
58
|
-
constructorName: "ChildrenManager",
|
|
59
|
-
constructor: import_managers.ChildrenManager
|
|
60
|
-
}
|
|
61
|
-
].forEach(({ prop, constructorName, constructor }) => {
|
|
62
|
-
instance[prop] = new instance.__managers[constructorName](instance);
|
|
63
|
-
if (import_utils2.isDev && !(instance[prop] instanceof constructor)) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`The \`$managers.${constructorName}\` must extend the \`${constructorName}\` class.`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
var Base = class extends EventTarget {
|
|
71
|
-
$parent = null;
|
|
72
|
-
$id;
|
|
73
|
-
$el;
|
|
74
|
-
$isMounted = false;
|
|
75
|
-
__eventHandlers = /* @__PURE__ */ new Map();
|
|
76
|
-
get $root() {
|
|
77
|
-
if (!this.$parent) {
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
let parent = this.$parent;
|
|
81
|
-
let root = this.$parent;
|
|
82
|
-
while (parent) {
|
|
83
|
-
if (!parent.$parent) {
|
|
84
|
-
root = parent;
|
|
85
|
-
}
|
|
86
|
-
parent = parent.$parent;
|
|
87
|
-
}
|
|
88
|
-
return root;
|
|
89
|
-
}
|
|
90
|
-
get __config() {
|
|
91
|
-
let proto = Object.getPrototypeOf(this);
|
|
92
|
-
let { config } = proto.constructor;
|
|
93
|
-
while (proto.constructor.config && proto.constructor.$isBase) {
|
|
94
|
-
config = { ...proto.constructor.config, ...config };
|
|
95
|
-
if (proto.constructor.config.options) {
|
|
96
|
-
config.options = { ...proto.constructor.config.options, ...config.options };
|
|
97
|
-
}
|
|
98
|
-
if (proto.constructor.config.emits && config.emits) {
|
|
99
|
-
config.emits = [...proto.constructor.config.emits, ...config.emits];
|
|
100
|
-
}
|
|
101
|
-
proto = Object.getPrototypeOf(proto);
|
|
102
|
-
}
|
|
103
|
-
config.options = config.options ?? {};
|
|
104
|
-
config.refs = config.refs ?? [];
|
|
105
|
-
config.components = config.components ?? {};
|
|
106
|
-
return config;
|
|
107
|
-
}
|
|
108
|
-
__services;
|
|
109
|
-
get $services() {
|
|
110
|
-
return this.__services;
|
|
111
|
-
}
|
|
112
|
-
__refs;
|
|
113
|
-
get $refs() {
|
|
114
|
-
return this.__refs;
|
|
115
|
-
}
|
|
116
|
-
__options;
|
|
117
|
-
get $options() {
|
|
118
|
-
return this.__options;
|
|
119
|
-
}
|
|
120
|
-
__children;
|
|
121
|
-
get $children() {
|
|
122
|
-
return this.__children;
|
|
123
|
-
}
|
|
124
|
-
__events;
|
|
125
|
-
get $log() {
|
|
126
|
-
return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : import_utils2.noop;
|
|
127
|
-
}
|
|
128
|
-
get $warn() {
|
|
129
|
-
return this.__options.log ? window.console.warn.bind(window, `[${this.__config.name}]`) : import_utils2.noop;
|
|
130
|
-
}
|
|
131
|
-
get __debug() {
|
|
132
|
-
return import_utils2.isDev && this.__options.debug ? window.console.log.bind(window, `[debug] [${this.$id}]`) : import_utils2.noop;
|
|
133
|
-
}
|
|
134
|
-
get __managers() {
|
|
135
|
-
return {
|
|
136
|
-
ChildrenManager: import_managers.ChildrenManager,
|
|
137
|
-
EventsManager: import_managers.EventsManager,
|
|
138
|
-
OptionsManager: import_managers.OptionsManager,
|
|
139
|
-
RefsManager: import_managers.RefsManager,
|
|
140
|
-
ServicesManager: import_managers.ServicesManager
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
__callMethod(method, ...args) {
|
|
144
|
-
if (import_utils2.isDev) {
|
|
145
|
-
this.__debug("callMethod", method, ...args);
|
|
146
|
-
}
|
|
147
|
-
this.$emit(method, ...args);
|
|
148
|
-
if (!(0, import_utils2.isFunction)(this[method])) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
if (import_utils2.isDev) {
|
|
152
|
-
this.__debug(method, this, ...args);
|
|
153
|
-
}
|
|
154
|
-
return this[method].call(this, ...args);
|
|
155
|
-
}
|
|
156
|
-
__hasEvent(event) {
|
|
157
|
-
const eventHandlers = this.__eventHandlers.get(event);
|
|
158
|
-
return eventHandlers && eventHandlers.size > 0;
|
|
159
|
-
}
|
|
160
|
-
constructor(element) {
|
|
161
|
-
super();
|
|
162
|
-
if (!element) {
|
|
163
|
-
if (import_utils2.isDev) {
|
|
164
|
-
throw new Error("The root element must be defined.");
|
|
165
|
-
}
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const { __config } = this;
|
|
169
|
-
if (__config.name === "Base") {
|
|
170
|
-
if (import_utils2.isDev) {
|
|
171
|
-
throw new Error("The `config.name` property is required.");
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
this.$id = `${__config.name}-${id}`;
|
|
176
|
-
id += 1;
|
|
177
|
-
this.$el = element;
|
|
178
|
-
if (!this.$el.__base__) {
|
|
179
|
-
this.$el.__base__ = /* @__PURE__ */ new WeakMap();
|
|
180
|
-
}
|
|
181
|
-
this.$el.__base__.set(this.__ctor, this);
|
|
182
|
-
createAndTestManagers(this);
|
|
183
|
-
if (import_utils2.isDev) {
|
|
184
|
-
this.__debug("constructor", this);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
$mount() {
|
|
188
|
-
if (this.$isMounted) {
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
this.$emit("before-mounted");
|
|
192
|
-
if (import_utils2.isDev) {
|
|
193
|
-
this.__debug("$mount");
|
|
194
|
-
}
|
|
195
|
-
[
|
|
196
|
-
() => this.$children.registerAll(),
|
|
197
|
-
() => this.$refs.registerAll(),
|
|
198
|
-
() => this.__events.bindRootElement(),
|
|
199
|
-
() => this.$services.enableAll(),
|
|
200
|
-
() => this.$children.mountAll(),
|
|
201
|
-
() => {
|
|
202
|
-
this.$isMounted = true;
|
|
203
|
-
},
|
|
204
|
-
() => this.__callMethod("mounted")
|
|
205
|
-
].forEach(import_utils.addToQueue);
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
$update() {
|
|
209
|
-
if (import_utils2.isDev) {
|
|
210
|
-
this.__debug("$update");
|
|
211
|
-
}
|
|
212
|
-
[
|
|
213
|
-
() => this.$refs.unregisterAll(),
|
|
214
|
-
() => this.$services.disableAll(),
|
|
215
|
-
() => this.$children.registerAll(),
|
|
216
|
-
() => this.$refs.registerAll(),
|
|
217
|
-
() => this.$services.enableAll(),
|
|
218
|
-
() => this.$children.updateAll(),
|
|
219
|
-
() => this.__callMethod("updated")
|
|
220
|
-
].forEach(import_utils.addToQueue);
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
$destroy() {
|
|
224
|
-
if (!this.$isMounted) {
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
if (import_utils2.isDev) {
|
|
228
|
-
this.__debug("$destroy");
|
|
229
|
-
}
|
|
230
|
-
[
|
|
231
|
-
() => {
|
|
232
|
-
this.$isMounted = false;
|
|
233
|
-
},
|
|
234
|
-
() => this.__events.unbindRootElement(),
|
|
235
|
-
() => this.$refs.unregisterAll(),
|
|
236
|
-
() => this.$services.disableAll(),
|
|
237
|
-
() => this.$children.destroyAll(),
|
|
238
|
-
() => this.__callMethod("destroyed")
|
|
239
|
-
].forEach(import_utils.addToQueue);
|
|
240
|
-
return this;
|
|
241
|
-
}
|
|
242
|
-
$terminate() {
|
|
243
|
-
if (import_utils2.isDev) {
|
|
244
|
-
this.__debug("$terminate");
|
|
245
|
-
}
|
|
246
|
-
[
|
|
247
|
-
() => this.$destroy(),
|
|
248
|
-
() => this.__callMethod("terminated"),
|
|
249
|
-
() => this.$el.__base__.set(this.__ctor, "terminated")
|
|
250
|
-
].forEach(import_utils.addToQueue);
|
|
251
|
-
}
|
|
252
|
-
__addEmits(event) {
|
|
253
|
-
const ctor = this.__ctor;
|
|
254
|
-
if ((0, import_utils2.isArray)(ctor.config.emits)) {
|
|
255
|
-
ctor.config.emits.push(event);
|
|
256
|
-
} else {
|
|
257
|
-
ctor.config.emits = [event];
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
__removeEmits(event) {
|
|
261
|
-
const ctor = this.__ctor;
|
|
262
|
-
const index = ctor.config.emits.indexOf(event);
|
|
263
|
-
ctor.config.emits.splice(index, 1);
|
|
264
|
-
}
|
|
265
|
-
get __ctor() {
|
|
266
|
-
return this.constructor;
|
|
267
|
-
}
|
|
268
|
-
$on(event, listener, options) {
|
|
269
|
-
if (import_utils2.isDev) {
|
|
270
|
-
this.__debug("$on", event, listener, options);
|
|
271
|
-
}
|
|
272
|
-
let set = this.__eventHandlers.get(event);
|
|
273
|
-
if (!set) {
|
|
274
|
-
set = /* @__PURE__ */ new Set();
|
|
275
|
-
this.__eventHandlers.set(event, set);
|
|
276
|
-
}
|
|
277
|
-
set.add(listener);
|
|
278
|
-
const target = (0, import_utils.getEventTarget)(this, event, this.__config);
|
|
279
|
-
target.addEventListener(event, listener, options);
|
|
280
|
-
return () => {
|
|
281
|
-
this.$off(event, listener, options);
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
$off(event, listener, options) {
|
|
285
|
-
if (import_utils2.isDev) {
|
|
286
|
-
this.__debug("$off", event, listener);
|
|
287
|
-
}
|
|
288
|
-
this.__eventHandlers.get(event).delete(listener);
|
|
289
|
-
const target = (0, import_utils.getEventTarget)(this, event, this.__config);
|
|
290
|
-
target.removeEventListener(event, listener, options);
|
|
291
|
-
}
|
|
292
|
-
$emit(event, ...args) {
|
|
293
|
-
if (import_utils2.isDev) {
|
|
294
|
-
this.__debug("$emit", event, args);
|
|
295
|
-
}
|
|
296
|
-
this.dispatchEvent(new CustomEvent(event, { detail: args }));
|
|
297
|
-
}
|
|
298
|
-
static $factory(nameOrSelector) {
|
|
299
|
-
if (import_utils2.isDev && !nameOrSelector) {
|
|
300
|
-
throw new Error(
|
|
301
|
-
"The $factory method requires a component\u2019s name or selector to be specified."
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
return (0, import_utils.getComponentElements)(nameOrSelector).map((el) => new this(el).$mount());
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
__publicField(Base, "$isBase", true);
|
|
308
|
-
__publicField(Base, "config", {
|
|
309
|
-
name: "Base",
|
|
310
|
-
emits: [
|
|
311
|
-
"before-mounted",
|
|
312
|
-
"mounted",
|
|
313
|
-
"updated",
|
|
314
|
-
"destroyed",
|
|
315
|
-
"terminated",
|
|
316
|
-
"ticked",
|
|
317
|
-
"scrolled",
|
|
318
|
-
"resized",
|
|
319
|
-
"moved",
|
|
320
|
-
"loaded",
|
|
321
|
-
"keyed"
|
|
322
|
-
]
|
|
323
|
-
});
|
|
324
|
-
if (module.exports.default) module.exports = module.exports.default;
|
|
325
|
-
//# sourceMappingURL=Base.cjs.map
|