rege 0.3.0 → 0.5.0

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.
@@ -1,5 +1,6 @@
1
- import { EventState, event } from 'reev/src'
2
- import { ResizeState } from './types'
1
+ import { event } from 'reev/src'
2
+ import type { EventState } from 'reev/src'
3
+ import type { ResizeState } from './types'
3
4
 
4
5
  export * from './types'
5
6
 
@@ -29,7 +30,7 @@ export const resizeEvent = <El extends Element = Element>(state: ResizeState) =>
29
30
 
30
31
  const clean = () => {}
31
32
 
32
- const ref = (el: El) => {
33
+ const ref = (el: El | null) => {
33
34
  self(state)
34
35
  if (el) {
35
36
  self.mount(el)
@@ -1,8 +1,8 @@
1
1
  import { resizeEvent } from '.'
2
2
  import { useMutable, useOnce } from 'reev/src/react'
3
- import { ResizeArg, ResizeState } from './types'
4
3
  import { isF } from '../utils'
5
4
  import type { ReactNode } from 'react'
5
+ import type { ResizeArg, ResizeState } from './types'
6
6
 
7
7
  export const useResize = (arg: ResizeArg) => {
8
8
  if (isF(arg)) arg = { resize: arg }
@@ -1,7 +1,8 @@
1
1
  import { vec2, addV, cpV, subV } from '../utils'
2
2
  import { scrollValues } from './utils'
3
- import { EventState, event } from 'reev/src'
4
- import { ScrollState } from './types'
3
+ import { event } from 'reev/src'
4
+ import type { EventState } from 'reev/src'
5
+ import type { ScrollState } from './types'
5
6
 
6
7
  export * from './types'
7
8
 
@@ -65,7 +66,7 @@ export const scrollEvent = <El extends Element = Element>(config?: ScrollState)
65
66
  window.removeEventListener('scroll', self.scrolling)
66
67
  }
67
68
 
68
- const ref = (el: Element | null) => {
69
+ const ref = (el: El | null) => {
69
70
  self(config as ScrollState<El>)
70
71
  if (el) {
71
72
  self.mount(el)
@@ -1,8 +1,8 @@
1
1
  import { useOnce, useMutable } from 'reev/src/react'
2
- import { ScrollConfig, ScrollState } from './types'
3
2
  import { scrollEvent } from './index'
4
3
  import { isF } from '../utils'
5
4
  import type { ReactNode } from 'react'
5
+ import type { ScrollConfig, ScrollState } from './types'
6
6
 
7
7
  export const useScroll = <El extends Element = Element>(config: ScrollConfig) => {
8
8
  if (isF(config)) config = { scroll: config }
@@ -1,4 +1,4 @@
1
- import { Vec2 } from '../utils'
1
+ import type { Vec2 } from '../utils'
2
2
 
3
3
  export interface ScrollState<El extends Element = Element> {
4
4
  _active: boolean
@@ -20,9 +20,9 @@ export interface ScrollState<El extends Element = Element> {
20
20
  scrollStart(e: Event): void
21
21
  scrolling(e: Event): void
22
22
  scrollEnd(e: Event): void
23
- mount(target: Element): void
23
+ mount(target: El): void
24
24
  clean(target: null): void
25
- ref(traget: Element): void
25
+ ref(traget: El | null): void
26
26
  tick?: () => void
27
27
  }
28
28
 
@@ -1,4 +1,5 @@
1
- import { vec2, Vec2 } from '../utils'
1
+ import { vec2 } from '../utils'
2
+ import type { Vec2 } from '../utils'
2
3
 
3
4
  export const scrollValues = (e: any, out = vec2()): Vec2 => {
4
5
  const { scrollX: x, scrollLeft: xx } = e.currentTarget
@@ -1,7 +1,8 @@
1
1
  import { vec2, addV, cpV } from '../utils'
2
2
  import { wheelValues } from './utils'
3
- import { EventState, event } from 'reev/src'
4
- import { WheelState } from './types'
3
+ import { event } from 'reev/src'
4
+ import type { EventState } from 'reev/src'
5
+ import type { WheelState } from './types'
5
6
 
6
7
  export * from './types'
7
8
 
@@ -62,7 +63,7 @@ export const wheelEvent = <El extends Element = Element>(config?: WheelState) =>
62
63
  target.removeEventListener('wheel', self.wheeling)
63
64
  }
64
65
 
65
- const ref = (el: Element | null) => {
66
+ const ref = (el: El | null) => {
66
67
  self(config as WheelState<El>)
67
68
  if (el) {
68
69
  self.mount(el)
@@ -1,8 +1,8 @@
1
1
  import { useOnce, useMutable } from 'reev/src/react'
2
- import { WheelConfig, WheelState } from './types'
3
2
  import { wheelEvent } from './index'
4
3
  import { isF } from '../utils'
5
4
  import type { ReactNode } from 'react'
5
+ import type { WheelConfig, WheelState } from './types'
6
6
 
7
7
  export const useWheel = <El extends Element = Element>(config: WheelConfig) => {
8
8
  if (isF(config)) config = { wheel: config }
@@ -1,4 +1,4 @@
1
- import { Vec2 } from '../utils'
1
+ import type { Vec2 } from '../utils'
2
2
 
3
3
  export interface WheelState<El extends Element = Element> {
4
4
  _active: boolean
@@ -20,9 +20,9 @@ export interface WheelState<El extends Element = Element> {
20
20
  wheelStart(e: Event): void
21
21
  wheeling(e: Event): void
22
22
  wheelEnd(e: Event): void
23
- mount(target: Element): void
23
+ mount(target: El): void
24
24
  clean(target: null): void
25
- ref(traget: Element | null): void
25
+ ref(traget: El | null): void
26
26
  tick?: () => void
27
27
  }
28
28
 
@@ -1,4 +1,5 @@
1
- import { vec2, Vec2 } from '../utils'
1
+ import { vec2 } from '../utils'
2
+ import type { Vec2 } from '../utils'
2
3
 
3
4
  const LINE_HEIGHT = 40
4
5