@octanejs/auto-animate 0.0.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/LICENSE +7 -0
- package/README.md +18 -0
- package/UPSTREAM.md +52 -0
- package/package.json +51 -0
- package/src/index.ts +6 -0
- package/src/react/index.tsrx +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2022 FormKit Inc.
|
|
2
|
+
|
|
3
|
+
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:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @octanejs/auto-animate
|
|
2
|
+
|
|
3
|
+
Octane binding for [`@formkit/auto-animate@0.10.0`](https://github.com/formkit/auto-animate). The vanilla `autoAnimate` core is reused unchanged. The React hook is ported at `@octanejs/auto-animate/react`.
|
|
4
|
+
|
|
5
|
+
```tsrx
|
|
6
|
+
import { useAutoAnimate } from '@octanejs/auto-animate/react';
|
|
7
|
+
|
|
8
|
+
export function List(props: { items: string[] }) @{
|
|
9
|
+
const [parent] = useAutoAnimate();
|
|
10
|
+
<ul ref={parent}>
|
|
11
|
+
@for (const item of props.items; key item) {
|
|
12
|
+
<li>{item}</li>
|
|
13
|
+
}
|
|
14
|
+
</ul>
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Vue, Preact, Solid, Angular, Nuxt, Marko, and Qwik entry points are not part of this binding. See [UPSTREAM.md](./UPSTREAM.md).
|
package/UPSTREAM.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Upstream provenance
|
|
2
|
+
|
|
3
|
+
`@octanejs/auto-animate` is pinned to `@formkit/auto-animate@0.10.0`.
|
|
4
|
+
|
|
5
|
+
- repository: https://github.com/formkit/auto-animate
|
|
6
|
+
- tag: `0.10.0`
|
|
7
|
+
- tag commit: `b6a6feebf75c198dd85f280c549bc0303f9e7aa8`
|
|
8
|
+
- advertised range: `0.10.x`
|
|
9
|
+
- license: MIT
|
|
10
|
+
- npm integrity: `sha512-KGomRttjUfORuPUaR/ZGQw+6xfMrTM+sxnILv7JAd9AmabU9rg9i6gF/iC0Ih+QpKCubJpCA/1DX9UHKE8cX+A==`
|
|
11
|
+
- npm shasum: `0eadd565f50e54e5dc6f29c41b32d32b53661eab`
|
|
12
|
+
|
|
13
|
+
## Source boundary
|
|
14
|
+
|
|
15
|
+
- `upstream/src/` is the canonical tagged source (vanilla core, framework adapters, tests, LICENSE).
|
|
16
|
+
- `upstream/npm/` is the published tarball (compiled `index.mjs` / `react/index.mjs`).
|
|
17
|
+
- The Octane package depends on `@formkit/auto-animate@0.10.0` and re-exports the vanilla core. Only `src/react/` is a port of `upstream/src/react/index.ts`.
|
|
18
|
+
|
|
19
|
+
Vendored evidence is development-only and excluded from package `files`.
|
|
20
|
+
|
|
21
|
+
## Export crosswalk
|
|
22
|
+
|
|
23
|
+
| Upstream export | Octane status | Evidence / divergence |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `autoAnimate` (`.`) | Reused verbatim from `@formkit/auto-animate` | `src/index.ts`; `tests/auto-animate.test.ts` |
|
|
26
|
+
| default export | Reused verbatim | `src/index.ts` |
|
|
27
|
+
| `getTransitionSizes` | Reused verbatim | `src/index.ts` |
|
|
28
|
+
| `vAutoAnimate` | Gap | Vue directive on the root package; Octane has no Vue renderer |
|
|
29
|
+
| `AutoAnimateOptions` / `AutoAnimationPlugin` / `AnimationController` | Reused types | `src/index.ts` |
|
|
30
|
+
| `./react` `useAutoAnimate` | Ported | `src/react/index.tsrx`; `tests/auto-animate.test.ts` |
|
|
31
|
+
| `./vue` | Gap | Other-framework adapter; Octane has no Vue renderer |
|
|
32
|
+
| `./preact` | Gap | Other-framework adapter |
|
|
33
|
+
| `./solid` | Gap | Other-framework adapter |
|
|
34
|
+
| `./angular` | Gap | Other-framework adapter |
|
|
35
|
+
| `./nuxt` | Gap | Nuxt module |
|
|
36
|
+
| `./marko` | Gap | Marko tag |
|
|
37
|
+
| `./qwik` (source only) | Gap | Not a published npm export at this pin; source exists in `upstream/src/qwik` |
|
|
38
|
+
|
|
39
|
+
## Upstream test disposition
|
|
40
|
+
|
|
41
|
+
| Upstream artifact | Disposition |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `upstream/src/index.ts` (vanilla) | Reused via npm dependency; not rewritten |
|
|
44
|
+
| `upstream/tests/` Playwright e2e (`tests/*.spec.ts`, multi-framework) | Out of scope: browser e2e across Vue/Preact/Solid/Angular/Nuxt/Marko/Qwik. Recorded as a gap, not skipped in-repo. |
|
|
45
|
+
| `playwright.config.ts` | Out of scope with the e2e suite |
|
|
46
|
+
|
|
47
|
+
Octane behavioral coverage is `tests/auto-animate.test.ts` (hook ref attach, enable/disable, omitted options). It is Octane-only framework-contract coverage because upstream ships no Vitest unit suite for the React hook.
|
|
48
|
+
|
|
49
|
+
## Intentional divergences
|
|
50
|
+
|
|
51
|
+
- Compiler-injected hook slots may occupy the `options` argument; a `symbol` is treated as omitted options.
|
|
52
|
+
- Non-React framework entry points are not published on `@octanejs/auto-animate`.
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octanejs/auto-animate",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Octane binding for @formkit/auto-animate 0.10.0: vanilla core reused, React useAutoAnimate ported.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.22.2"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Dominic Gannaway",
|
|
12
|
+
"email": "dg@domgan.com"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/octanejs/octane.git",
|
|
20
|
+
"directory": "packages/auto-animate"
|
|
21
|
+
},
|
|
22
|
+
"main": "./src/index.ts",
|
|
23
|
+
"module": "./src/index.ts",
|
|
24
|
+
"types": "./src/index.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"README.md",
|
|
28
|
+
"UPSTREAM.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./src/index.ts",
|
|
33
|
+
"./react": "./src/react/index.tsrx",
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@formkit/auto-animate": "0.10.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"octane": "0.1.45"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"vitest": "^4.1.10",
|
|
44
|
+
"@octanejs/testing-library": "0.1.42",
|
|
45
|
+
"octane": "0.1.45"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "vitest run --root ../.. --config vitest.config.js --project auto-animate",
|
|
49
|
+
"typecheck": "tsrx-tsc --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState, useCallback, useMemo, useEffect } from 'octane';
|
|
2
|
+
import autoAnimate from '@formkit/auto-animate';
|
|
3
|
+
import type {
|
|
4
|
+
AutoAnimateOptions,
|
|
5
|
+
AutoAnimationPlugin,
|
|
6
|
+
AnimationController,
|
|
7
|
+
} from '@formkit/auto-animate';
|
|
8
|
+
|
|
9
|
+
type AutoAnimateRefCallback<T extends Element> = (node: T | null) => void;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* AutoAnimate hook for adding dead-simple transitions and animations.
|
|
13
|
+
* Per packages/auto-animate/upstream/src/react/index.ts
|
|
14
|
+
*/
|
|
15
|
+
export function useAutoAnimate<T extends Element>(
|
|
16
|
+
options?: Partial<AutoAnimateOptions> | AutoAnimationPlugin | symbol,
|
|
17
|
+
): [AutoAnimateRefCallback<T>, (enabled: boolean) => void] {
|
|
18
|
+
// OCTANE DIVERGENCE: compiler injects a trailing hook slot; when the hook
|
|
19
|
+
// is called with no options the slot lands in the first argument.
|
|
20
|
+
const resolvedOptions =
|
|
21
|
+
typeof options === 'symbol' ? undefined : options;
|
|
22
|
+
const [controller, setController] = useState<AnimationController | undefined>();
|
|
23
|
+
const memoizedOptions = useMemo(function memoOptions() {
|
|
24
|
+
return resolvedOptions;
|
|
25
|
+
}, []);
|
|
26
|
+
const element = useCallback(function bindElement(node: T | null) {
|
|
27
|
+
if (node instanceof HTMLElement) {
|
|
28
|
+
setController(autoAnimate(node, memoizedOptions));
|
|
29
|
+
} else {
|
|
30
|
+
setController(undefined);
|
|
31
|
+
}
|
|
32
|
+
}, [memoizedOptions]);
|
|
33
|
+
const setEnabled = useCallback(function setEnabled(enabled: boolean) {
|
|
34
|
+
if (controller) {
|
|
35
|
+
if (enabled) {
|
|
36
|
+
controller.enable();
|
|
37
|
+
} else {
|
|
38
|
+
controller.disable();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, [controller]);
|
|
42
|
+
|
|
43
|
+
useEffect(function destroyController() {
|
|
44
|
+
return function onUnmount() {
|
|
45
|
+
controller?.destroy?.();
|
|
46
|
+
};
|
|
47
|
+
}, [controller]);
|
|
48
|
+
|
|
49
|
+
return [element, setEnabled];
|
|
50
|
+
}
|