Initial commit

This commit is contained in:
Ammaar Reshi
2025-01-04 14:06:53 +00:00
parent 7082408604
commit d6025af146
23760 changed files with 3299690 additions and 0 deletions

9
node_modules/motion-dom/.turbo/turbo-build.log generated vendored Normal file
View File

@ -0,0 +1,9 @@

lib/index.js → dist/cjs...
created dist/cjs in 22ms

lib/index.js → dist/es...
created dist/es in 11ms

types/index.d.ts → dist/index.d.ts...
created dist/index.d.ts in 18ms

21
node_modules/motion-dom/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 [Framer](https://www.framer.com?utm_source=motion-license) B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

105
node_modules/motion-dom/dist/cjs/index.js generated vendored Normal file
View File

@ -0,0 +1,105 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function resolveElements(elementOrSelector, scope, selectorCache) {
var _a;
if (elementOrSelector instanceof Element) {
return [elementOrSelector];
}
else if (typeof elementOrSelector === "string") {
let root = document;
if (scope) {
// TODO: Refactor to utils package
// invariant(
// Boolean(scope.current),
// "Scope provided, but no element detected."
// )
root = scope.current;
}
const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
return elements ? Array.from(elements) : [];
}
return Array.from(elementOrSelector);
}
const isDragging = {
x: false,
y: false,
};
function isDragActive() {
return isDragging.x || isDragging.y;
}
/**
* Filter out events that are not pointer events, or are triggering
* while a Motion gesture is active.
*/
function filterEvents(callback) {
return (event) => {
if (event.pointerType === "touch" || isDragActive())
return;
callback(event);
};
}
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
function hover(elementOrSelector, onHoverStart, options = {}) {
const gestureAbortController = new AbortController();
const eventOptions = {
passive: true,
...options,
signal: gestureAbortController.signal,
};
const onPointerEnter = filterEvents((enterEvent) => {
const { target } = enterEvent;
const onHoverEnd = onHoverStart(enterEvent);
if (!onHoverEnd || !target)
return;
const onPointerLeave = filterEvents((leaveEvent) => {
onHoverEnd(leaveEvent);
target.removeEventListener("pointerleave", onPointerLeave);
});
target.addEventListener("pointerleave", onPointerLeave, eventOptions);
});
resolveElements(elementOrSelector).forEach((element) => {
element.addEventListener("pointerenter", onPointerEnter, eventOptions);
});
return () => gestureAbortController.abort();
}
function setDragLock(axis) {
if (axis === "x" || axis === "y") {
if (isDragging[axis]) {
return null;
}
else {
isDragging[axis] = true;
return () => {
isDragging[axis] = false;
};
}
}
else {
if (isDragging.x || isDragging.y) {
return null;
}
else {
isDragging.x = isDragging.y = true;
return () => {
isDragging.x = isDragging.y = false;
};
}
}
}
exports.hover = hover;
exports.isDragActive = isDragActive;
exports.isDragging = isDragging;
exports.resolveElements = resolveElements;
exports.setDragLock = setDragLock;

View File

@ -0,0 +1,9 @@
const isDragging = {
x: false,
y: false,
};
function isDragActive() {
return isDragging.x || isDragging.y;
}
export { isDragActive, isDragging };

View File

@ -0,0 +1,28 @@
import { isDragging } from './is-active.mjs';
function setDragLock(axis) {
if (axis === "x" || axis === "y") {
if (isDragging[axis]) {
return null;
}
else {
isDragging[axis] = true;
return () => {
isDragging[axis] = false;
};
}
}
else {
if (isDragging.x || isDragging.y) {
return null;
}
else {
isDragging.x = isDragging.y = true;
return () => {
isDragging.x = isDragging.y = false;
};
}
}
}
export { setDragLock };

46
node_modules/motion-dom/dist/es/gestures/hover.mjs generated vendored Normal file
View File

@ -0,0 +1,46 @@
import { resolveElements } from '../utils/resolve-elements.mjs';
import { isDragActive } from './drag/state/is-active.mjs';
/**
* Filter out events that are not pointer events, or are triggering
* while a Motion gesture is active.
*/
function filterEvents(callback) {
return (event) => {
if (event.pointerType === "touch" || isDragActive())
return;
callback(event);
};
}
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
function hover(elementOrSelector, onHoverStart, options = {}) {
const gestureAbortController = new AbortController();
const eventOptions = {
passive: true,
...options,
signal: gestureAbortController.signal,
};
const onPointerEnter = filterEvents((enterEvent) => {
const { target } = enterEvent;
const onHoverEnd = onHoverStart(enterEvent);
if (!onHoverEnd || !target)
return;
const onPointerLeave = filterEvents((leaveEvent) => {
onHoverEnd(leaveEvent);
target.removeEventListener("pointerleave", onPointerLeave);
});
target.addEventListener("pointerleave", onPointerLeave, eventOptions);
});
resolveElements(elementOrSelector).forEach((element) => {
element.addEventListener("pointerenter", onPointerEnter, eventOptions);
});
return () => gestureAbortController.abort();
}
export { hover };

4
node_modules/motion-dom/dist/es/index.mjs generated vendored Normal file
View File

@ -0,0 +1,4 @@
export { hover } from './gestures/hover.mjs';
export { resolveElements } from './utils/resolve-elements.mjs';
export { isDragActive, isDragging } from './gestures/drag/state/is-active.mjs';
export { setDragLock } from './gestures/drag/state/set-active.mjs';

View File

@ -0,0 +1,22 @@
function resolveElements(elementOrSelector, scope, selectorCache) {
var _a;
if (elementOrSelector instanceof Element) {
return [elementOrSelector];
}
else if (typeof elementOrSelector === "string") {
let root = document;
if (scope) {
// TODO: Refactor to utils package
// invariant(
// Boolean(scope.current),
// "Scope provided, but no element detected."
// )
root = scope.current;
}
const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
return elements ? Array.from(elements) : [];
}
return Array.from(elementOrSelector);
}
export { resolveElements };

66
node_modules/motion-dom/dist/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,66 @@
type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
interface WithQuerySelectorAll {
querySelectorAll: Element["querySelectorAll"];
}
interface AnimationScope<T = any> {
readonly current: T;
animations: any[];
}
interface SelectorCache {
[key: string]: NodeListOf<Element>;
}
declare function resolveElements(elementOrSelector: ElementOrSelector, scope?: AnimationScope, selectorCache?: SelectorCache): Element[];
/**
* Options for the hover gesture.
*
* @public
*/
interface HoverOptions {
/**
* Use passive event listeners. Doing so allows the browser to optimize
* scrolling performance by not allowing the use of `preventDefault()`.
*
* @default true
*/
passive?: boolean;
/**
* Remove the event listener after the first event.
*
* @default false
*/
once?: boolean;
}
/**
* A function to be called when a hover gesture starts.
*
* This function can optionally return a function that will be called
* when the hover gesture ends.
*
* @public
*/
type OnHoverStartEvent = (event: PointerEvent) => void | OnHoverEndEvent;
/**
* A function to be called when a hover gesture ends.
*
* @public
*/
type OnHoverEndEvent = (event: PointerEvent) => void;
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
declare function hover(elementOrSelector: ElementOrSelector, onHoverStart: OnHoverStartEvent, options?: HoverOptions): () => void;
declare const isDragging: {
x: boolean;
y: boolean;
};
declare function isDragActive(): boolean;
declare function setDragLock(axis: boolean | "x" | "y" | "lockDirection"): (() => void) | null;
export { type AnimationScope, type ElementOrSelector, type HoverOptions, type OnHoverEndEvent, type OnHoverStartEvent, type SelectorCache, type WithQuerySelectorAll, hover, isDragActive, isDragging, resolveElements, setDragLock };

View File

@ -0,0 +1,8 @@
export const isDragging = {
x: false,
y: false,
};
export function isDragActive() {
return isDragging.x || isDragging.y;
}
//# sourceMappingURL=is-active.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"is-active.js","sourceRoot":"","sources":["../../../../src/gestures/drag/state/is-active.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;CACX,CAAA;AAED,MAAM,UAAU,YAAY;IACxB,OAAO,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAA;AACvC,CAAC"}

View File

@ -0,0 +1,26 @@
import { isDragging } from "./is-active";
export function setDragLock(axis) {
if (axis === "x" || axis === "y") {
if (isDragging[axis]) {
return null;
}
else {
isDragging[axis] = true;
return () => {
isDragging[axis] = false;
};
}
}
else {
if (isDragging.x || isDragging.y) {
return null;
}
else {
isDragging.x = isDragging.y = true;
return () => {
isDragging.x = isDragging.y = false;
};
}
}
}
//# sourceMappingURL=set-active.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"set-active.js","sourceRoot":"","sources":["../../../../src/gestures/drag/state/set-active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,UAAU,WAAW,CAAC,IAA2C;IACnE,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACf,CAAC;aAAM,CAAC;YACJ,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;YACvB,OAAO,GAAG,EAAE;gBACR,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;YAC5B,CAAC,CAAA;QACL,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,IAAI,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAA;QACf,CAAC;aAAM,CAAC;YACJ,UAAU,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,CAAA;YAClC,OAAO,GAAG,EAAE;gBACR,UAAU,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,KAAK,CAAA;YACvC,CAAC,CAAA;QACL,CAAC;IACL,CAAC;AACL,CAAC"}

44
node_modules/motion-dom/lib/gestures/hover.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
import { resolveElements } from "../utils/resolve-elements";
import { isDragActive } from "./drag/state/is-active";
/**
* Filter out events that are not pointer events, or are triggering
* while a Motion gesture is active.
*/
function filterEvents(callback) {
return (event) => {
if (event.pointerType === "touch" || isDragActive())
return;
callback(event);
};
}
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
export function hover(elementOrSelector, onHoverStart, options = {}) {
const gestureAbortController = new AbortController();
const eventOptions = {
passive: true,
...options,
signal: gestureAbortController.signal,
};
const onPointerEnter = filterEvents((enterEvent) => {
const { target } = enterEvent;
const onHoverEnd = onHoverStart(enterEvent);
if (!onHoverEnd || !target)
return;
const onPointerLeave = filterEvents((leaveEvent) => {
onHoverEnd(leaveEvent);
target.removeEventListener("pointerleave", onPointerLeave);
});
target.addEventListener("pointerleave", onPointerLeave, eventOptions);
});
resolveElements(elementOrSelector).forEach((element) => {
element.addEventListener("pointerenter", onPointerEnter, eventOptions);
});
return () => gestureAbortController.abort();
}
//# sourceMappingURL=hover.js.map

1
node_modules/motion-dom/lib/gestures/hover.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"hover.js","sourceRoot":"","sources":["../../src/gestures/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAyCrD;;;GAGG;AACH,SAAS,YAAY,CAAC,QAA2B;IAC7C,OAAO,CAAC,KAAmB,EAAE,EAAE;QAC3B,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,IAAI,YAAY,EAAE;YAAE,OAAM;QAC3D,QAAQ,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC,CAAA;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CACjB,iBAAoC,EACpC,YAA+B,EAC/B,UAAwB,EAAE;IAE1B,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAA;IAEpD,MAAM,YAAY,GAAG;QACjB,OAAO,EAAE,IAAI;QACb,GAAG,OAAO;QACV,MAAM,EAAE,sBAAsB,CAAC,MAAM;KACxC,CAAA;IAED,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,UAAwB,EAAE,EAAE;QAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;QAC7B,MAAM,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA;QAE3C,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM;YAAE,OAAM;QAElC,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,UAAwB,EAAE,EAAE;YAC7D,UAAU,CAAC,UAAU,CAAC,CAAA;YACtB,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;QAC9D,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,eAAe,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACnD,OAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IAC1E,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAA;AAC/C,CAAC"}

5
node_modules/motion-dom/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
export * from "./gestures/hover";
export * from "./utils/resolve-elements";
export * from "./gestures/drag/state/is-active";
export * from "./gestures/drag/state/set-active";
//# sourceMappingURL=index.js.map

1
node_modules/motion-dom/lib/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAEhC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA"}

21
node_modules/motion-dom/lib/utils/resolve-elements.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
export function resolveElements(elementOrSelector, scope, selectorCache) {
var _a;
if (elementOrSelector instanceof Element) {
return [elementOrSelector];
}
else if (typeof elementOrSelector === "string") {
let root = document;
if (scope) {
// TODO: Refactor to utils package
// invariant(
// Boolean(scope.current),
// "Scope provided, but no element detected."
// )
root = scope.current;
}
const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
return elements ? Array.from(elements) : [];
}
return Array.from(elementOrSelector);
}
//# sourceMappingURL=resolve-elements.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"resolve-elements.js","sourceRoot":"","sources":["../../src/utils/resolve-elements.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,eAAe,CAC3B,iBAAoC,EACpC,KAAsB,EACtB,aAA6B;;IAE7B,IAAI,iBAAiB,YAAY,OAAO,EAAE,CAAC;QACvC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC9B,CAAC;SAAM,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC/C,IAAI,IAAI,GAAyB,QAAQ,CAAA;QAEzC,IAAI,KAAK,EAAE,CAAC;YACR,kCAAkC;YAClC,aAAa;YACb,8BAA8B;YAC9B,iDAAiD;YACjD,IAAI;YACJ,IAAI,GAAG,KAAK,CAAC,OAAO,CAAA;QACxB,CAAC;QAED,MAAM,QAAQ,GACV,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,iBAAiB,CAAC,mCAClC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;QAE5C,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;AACxC,CAAC"}

27
node_modules/motion-dom/package.json generated vendored Normal file
View File

@ -0,0 +1,27 @@
{
"name": "motion-dom",
"version": "11.13.0",
"main": "./lib/index.js",
"types": "./types/index.d.ts",
"module": "./lib/index.js",
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.mjs",
"default": "./lib/index.js"
},
"./hover": {
"types": "./types/gestures/hover.d.ts",
"require": "./dist/cjs/gestures/hover.js",
"import": "./dist/es/gestures/hover.mjs",
"default": "./lib/gestures/hover.js"
}
},
"scripts": {
"clean": "rm -rf types dist lib",
"build": "yarn clean && tsc -p . && rollup -c",
"dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\""
},
"gitHead": "c6ea900aecfec3e946a0f33db4672e0194f3048b"
}

94
node_modules/motion-dom/rollup.config.mjs generated vendored Normal file
View File

@ -0,0 +1,94 @@
import resolve from "@rollup/plugin-node-resolve"
import replace from "@rollup/plugin-replace"
import dts from "rollup-plugin-dts"
import pkg from "./package.json" with { type: "json"}
import tsconfig from "./tsconfig.json" with { type: "json" }
import preserveDirectives from "rollup-plugin-preserve-directives";
const config = {
input: "lib/index.js",
}
export const replaceSettings = (env) => {
const replaceConfig = env
? {
"process.env.NODE_ENV": JSON.stringify(env),
preventAssignment: false,
}
: {
preventAssignment: false,
}
replaceConfig.__VERSION__ = `${pkg.version}`
return replace(replaceConfig)
}
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(pkg.optionalDependencies || {}),
"react/jsx-runtime",
]
const cjs = Object.assign({}, config, {
input: "lib/index.js",
output: {
entryFileNames: `[name].js`,
dir: "dist/cjs",
format: "cjs",
exports: "named",
esModule: true
},
plugins: [resolve(), replaceSettings()],
external,
onwarn(warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return
}
warn(warning)
}
})
export const es = Object.assign({}, config, {
input: ["lib/index.js"],
output: {
entryFileNames: "[name].mjs",
format: "es",
exports: "named",
preserveModules: true,
dir: "dist/es",
},
plugins: [resolve(), replaceSettings(), preserveDirectives()],
external,
onwarn(warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return
}
warn(warning)
}
})
const typePlugins = [dts({compilerOptions: {...tsconfig, baseUrl:"types"}})]
function createTypes(input, file) {
return {
input,
output: {
format: "es",
file: file,
},
plugins: typePlugins,
}
}
const types = createTypes("types/index.d.ts", "dist/index.d.ts")
// eslint-disable-next-line import/no-default-export
export default [
cjs,
es,
types,
]

View File

@ -0,0 +1,8 @@
export const isDragging = {
x: false,
y: false,
}
export function isDragActive() {
return isDragging.x || isDragging.y
}

View File

@ -0,0 +1,23 @@
import { isDragging } from "./is-active"
export function setDragLock(axis: boolean | "x" | "y" | "lockDirection") {
if (axis === "x" || axis === "y") {
if (isDragging[axis]) {
return null
} else {
isDragging[axis] = true
return () => {
isDragging[axis] = false
}
}
} else {
if (isDragging.x || isDragging.y) {
return null
} else {
isDragging.x = isDragging.y = true
return () => {
isDragging.x = isDragging.y = false
}
}
}
}

93
node_modules/motion-dom/src/gestures/hover.ts generated vendored Normal file
View File

@ -0,0 +1,93 @@
import { ElementOrSelector, resolveElements } from "../utils/resolve-elements"
import { isDragActive } from "./drag/state/is-active"
/**
* Options for the hover gesture.
*
* @public
*/
export interface HoverOptions {
/**
* Use passive event listeners. Doing so allows the browser to optimize
* scrolling performance by not allowing the use of `preventDefault()`.
*
* @default true
*/
passive?: boolean
/**
* Remove the event listener after the first event.
*
* @default false
*/
once?: boolean
}
/**
* A function to be called when a hover gesture starts.
*
* This function can optionally return a function that will be called
* when the hover gesture ends.
*
* @public
*/
export type OnHoverStartEvent = (event: PointerEvent) => void | OnHoverEndEvent
/**
* A function to be called when a hover gesture ends.
*
* @public
*/
export type OnHoverEndEvent = (event: PointerEvent) => void
/**
* Filter out events that are not pointer events, or are triggering
* while a Motion gesture is active.
*/
function filterEvents(callback: OnHoverStartEvent) {
return (event: PointerEvent) => {
if (event.pointerType === "touch" || isDragActive()) return
callback(event)
}
}
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
export function hover(
elementOrSelector: ElementOrSelector,
onHoverStart: OnHoverStartEvent,
options: HoverOptions = {}
) {
const gestureAbortController = new AbortController()
const eventOptions = {
passive: true,
...options,
signal: gestureAbortController.signal,
}
const onPointerEnter = filterEvents((enterEvent: PointerEvent) => {
const { target } = enterEvent
const onHoverEnd = onHoverStart(enterEvent)
if (!onHoverEnd || !target) return
const onPointerLeave = filterEvents((leaveEvent: PointerEvent) => {
onHoverEnd(leaveEvent)
target.removeEventListener("pointerleave", onPointerLeave)
})
target.addEventListener("pointerleave", onPointerLeave, eventOptions)
})
resolveElements(elementOrSelector).forEach((element) => {
element.addEventListener("pointerenter", onPointerEnter, eventOptions)
})
return () => gestureAbortController.abort()
}

5
node_modules/motion-dom/src/index.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
export * from "./gestures/hover"
export * from "./utils/resolve-elements"
export * from "./gestures/drag/state/is-active"
export * from "./gestures/drag/state/set-active"

47
node_modules/motion-dom/src/utils/resolve-elements.ts generated vendored Normal file
View File

@ -0,0 +1,47 @@
export type ElementOrSelector =
| Element
| Element[]
| NodeListOf<Element>
| string
export interface WithQuerySelectorAll {
querySelectorAll: Element["querySelectorAll"]
}
export interface AnimationScope<T = any> {
readonly current: T
animations: any[] // TODO: Refactor to types package AnimationPlaybackControls[]
}
export interface SelectorCache {
[key: string]: NodeListOf<Element>
}
export function resolveElements(
elementOrSelector: ElementOrSelector,
scope?: AnimationScope,
selectorCache?: SelectorCache
): Element[] {
if (elementOrSelector instanceof Element) {
return [elementOrSelector]
} else if (typeof elementOrSelector === "string") {
let root: WithQuerySelectorAll = document
if (scope) {
// TODO: Refactor to utils package
// invariant(
// Boolean(scope.current),
// "Scope provided, but no element detected."
// )
root = scope.current
}
const elements =
selectorCache?.[elementOrSelector] ??
root.querySelectorAll(elementOrSelector)
return elements ? Array.from(elements) : []
}
return Array.from(elementOrSelector)
}

25
node_modules/motion-dom/tsconfig.json generated vendored Normal file
View File

@ -0,0 +1,25 @@
{
"extends": "config/tsconfig.json",
"filesGlob": ["./src/**/*.ts"],
"exclude": [
"node_modules",
"build",
"**/__tests__/*",
"jest.setup.tsx",
"dev",
"types",
"dev/examples.framer",
"test",
"skins",
"dist",
"temp",
"api",
"cypress"
],
"compilerOptions": {
"baseUrl": "src",
"declarationDir": "types",
"outDir": "lib",
"rootDir": "src"
}
}

View File

@ -0,0 +1,5 @@
export declare const isDragging: {
x: boolean;
y: boolean;
};
export declare function isDragActive(): boolean;

View File

@ -0,0 +1 @@
export declare function setDragLock(axis: boolean | "x" | "y" | "lockDirection"): (() => void) | null;

44
node_modules/motion-dom/types/gestures/hover.d.ts generated vendored Normal file
View File

@ -0,0 +1,44 @@
import { ElementOrSelector } from "../utils/resolve-elements";
/**
* Options for the hover gesture.
*
* @public
*/
export interface HoverOptions {
/**
* Use passive event listeners. Doing so allows the browser to optimize
* scrolling performance by not allowing the use of `preventDefault()`.
*
* @default true
*/
passive?: boolean;
/**
* Remove the event listener after the first event.
*
* @default false
*/
once?: boolean;
}
/**
* A function to be called when a hover gesture starts.
*
* This function can optionally return a function that will be called
* when the hover gesture ends.
*
* @public
*/
export type OnHoverStartEvent = (event: PointerEvent) => void | OnHoverEndEvent;
/**
* A function to be called when a hover gesture ends.
*
* @public
*/
export type OnHoverEndEvent = (event: PointerEvent) => void;
/**
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
*
* @public
*/
export declare function hover(elementOrSelector: ElementOrSelector, onHoverStart: OnHoverStartEvent, options?: HoverOptions): () => void;

4
node_modules/motion-dom/types/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
export * from "./gestures/hover";
export * from "./utils/resolve-elements";
export * from "./gestures/drag/state/is-active";
export * from "./gestures/drag/state/set-active";

View File

@ -0,0 +1,12 @@
export type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
export interface WithQuerySelectorAll {
querySelectorAll: Element["querySelectorAll"];
}
export interface AnimationScope<T = any> {
readonly current: T;
animations: any[];
}
export interface SelectorCache {
[key: string]: NodeListOf<Element>;
}
export declare function resolveElements(elementOrSelector: ElementOrSelector, scope?: AnimationScope, selectorCache?: SelectorCache): Element[];