@codeleap/web 3.18.7 → 3.18.9
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/package.json +1 -1
- package/src/components/Slider/index.tsx +16 -12
- package/src/components/Text/index.tsx +9 -1
- package/src/components/Text/types.ts +14 -12
- package/src/components/TextInput/index.tsx +4 -0
- package/src/components/Tooltip/index.tsx +12 -4
- package/src/components/Tooltip/styles.ts +7 -2
- package/src/components/Touchable/index.tsx +4 -1
- package/src/components/View/index.tsx +16 -32
- package/src/components/View/types.ts +22 -0
- package/src/index.ts +1 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/useAnimatedStyle.ts +28 -0
- package/src/lib/useBreakpointMatch.ts +1 -1
- package/src/lib/utils/index.ts +2 -0
- package/src/lib/utils/test.ts +3 -0
package/package.json
CHANGED
|
@@ -27,14 +27,14 @@ export type SliderProps = Partial<Omit<PrimitiveSliderProps, 'value' | 'onValueC
|
|
|
27
27
|
separator?: string
|
|
28
28
|
transformer?: (value: number[], defaultValue: PrimitiveSliderProps['defaultValue']) => string
|
|
29
29
|
}
|
|
30
|
-
value: number[]
|
|
31
|
-
onValueChange: (val: number[]) => void
|
|
30
|
+
value: number | number[]
|
|
31
|
+
onValueChange: (val: number | number[]) => void
|
|
32
32
|
styles?: StylesOf<SliderComposition>
|
|
33
33
|
style?: PropsOf<typeof View>['style']
|
|
34
34
|
trackMarks?: Record<number, string>
|
|
35
35
|
trackMarkComponent?: React.ComponentType<TrackMarkProps>
|
|
36
36
|
onPressThumbSetValue?: boolean
|
|
37
|
-
onPressThumb?: (value: number, thumbIndex: number) => void
|
|
37
|
+
onPressThumb?: (value: number | number[], thumbIndex: number) => void
|
|
38
38
|
} & ComponentVariants<typeof SliderPresets>
|
|
39
39
|
|
|
40
40
|
export type TrackMarkProps = {
|
|
@@ -67,7 +67,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
67
67
|
const {
|
|
68
68
|
debounce = null,
|
|
69
69
|
onValueChange,
|
|
70
|
-
value,
|
|
70
|
+
value: _value,
|
|
71
71
|
label,
|
|
72
72
|
debugName,
|
|
73
73
|
styles = {},
|
|
@@ -77,7 +77,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
77
77
|
variants,
|
|
78
78
|
trackMarks,
|
|
79
79
|
trackMarkComponent = DefaultSliderTrackMark,
|
|
80
|
-
defaultValue:
|
|
80
|
+
defaultValue: defaultSliderValue = [],
|
|
81
81
|
max = 100,
|
|
82
82
|
min = 0,
|
|
83
83
|
indicatorLabel = null,
|
|
@@ -89,6 +89,10 @@ export const Slider = (props: SliderProps) => {
|
|
|
89
89
|
...sliderProps
|
|
90
90
|
} = others
|
|
91
91
|
|
|
92
|
+
const isUniqueValue = !TypeGuards.isArray(_value)
|
|
93
|
+
const value = isUniqueValue ? [_value] : _value
|
|
94
|
+
const _defaultValue = TypeGuards.isArray(defaultSliderValue) ? defaultSliderValue : [defaultSliderValue]
|
|
95
|
+
|
|
92
96
|
const defaultValueRef = useRef<PrimitiveSliderProps['defaultValue']>(_defaultValue)
|
|
93
97
|
const defaultValue = defaultValueRef.current
|
|
94
98
|
|
|
@@ -102,9 +106,9 @@ export const Slider = (props: SliderProps) => {
|
|
|
102
106
|
|
|
103
107
|
const currentThumbRef = useRef(null)
|
|
104
108
|
|
|
105
|
-
const handleChange: SliderProps['onValueChange'] = (newValue) => {
|
|
106
|
-
if (
|
|
107
|
-
onValueChange(newValue)
|
|
109
|
+
const handleChange: SliderProps['onValueChange'] = (newValue: Array<number>) => {
|
|
110
|
+
if (isUniqueValue) {
|
|
111
|
+
onValueChange(newValue?.[0])
|
|
108
112
|
return
|
|
109
113
|
}
|
|
110
114
|
|
|
@@ -244,15 +248,15 @@ export const Slider = (props: SliderProps) => {
|
|
|
244
248
|
<SliderRange style={selectedTrackStyle} />
|
|
245
249
|
</SliderTrack>
|
|
246
250
|
|
|
247
|
-
{defaultValue.map((
|
|
251
|
+
{defaultValue.map((_, i) => (
|
|
248
252
|
<SliderThumb
|
|
249
253
|
key={i}
|
|
250
|
-
// @ts-ignore
|
|
251
254
|
index={i}
|
|
252
255
|
style={thumbStyle}
|
|
253
256
|
onClick={() => {
|
|
254
|
-
if (onPressThumbSetValue) onValueChange?.(
|
|
255
|
-
if (TypeGuards.isFunction(onPressThumb)) onPressThumb?.(
|
|
257
|
+
if (onPressThumbSetValue) onValueChange?.(value)
|
|
258
|
+
if (TypeGuards.isFunction(onPressThumb)) onPressThumb?.(value, i)
|
|
259
|
+
|
|
256
260
|
currentThumbRef.current = i
|
|
257
261
|
}}
|
|
258
262
|
onMouseEnter={() => currentThumbRef.current = i}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
|
|
2
|
+
import { motion } from 'framer-motion'
|
|
2
3
|
import React, { ElementType } from 'react'
|
|
3
4
|
import { TextPresets } from './styles'
|
|
4
5
|
import { TextProps } from './types'
|
|
@@ -11,6 +12,8 @@ const defaultProps: Partial<TextProps<'p'>> = {
|
|
|
11
12
|
component: 'p',
|
|
12
13
|
debounce: null,
|
|
13
14
|
pressDisabled: false,
|
|
15
|
+
animated: false,
|
|
16
|
+
animatedProps: {},
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export const Text = <T extends ElementType>(textProps: TextProps<T>) => {
|
|
@@ -27,16 +30,20 @@ export const Text = <T extends ElementType>(textProps: TextProps<T>) => {
|
|
|
27
30
|
css,
|
|
28
31
|
text = null,
|
|
29
32
|
children,
|
|
30
|
-
component
|
|
33
|
+
component,
|
|
31
34
|
debugName,
|
|
32
35
|
msg = null,
|
|
33
36
|
onPress,
|
|
34
37
|
debounce,
|
|
35
38
|
pressDisabled,
|
|
36
39
|
onClick,
|
|
40
|
+
animated,
|
|
41
|
+
animatedProps,
|
|
37
42
|
...props
|
|
38
43
|
} = allProps
|
|
39
44
|
|
|
45
|
+
const Component = animated ? (motion?.[component] || motion.p) : (component || 'p')
|
|
46
|
+
|
|
40
47
|
const pressedRef = React.useRef(false)
|
|
41
48
|
|
|
42
49
|
const variantStyles = useDefaultComponentStyle<'u:Text', typeof TextPresets>('u:Text', {
|
|
@@ -89,6 +96,7 @@ export const Text = <T extends ElementType>(textProps: TextProps<T>) => {
|
|
|
89
96
|
css={_styles}
|
|
90
97
|
{...props}
|
|
91
98
|
{...pressProps}
|
|
99
|
+
{...animatedProps}
|
|
92
100
|
>
|
|
93
101
|
{text || children}
|
|
94
102
|
</Component>
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { StylesOf, ComponentVariants } from '@codeleap/common'
|
|
2
|
+
import { MotionProps } from 'framer-motion'
|
|
2
3
|
import { ComponentPropsWithoutRef, ElementType } from 'react'
|
|
3
4
|
import { TextComposition, TextPresets } from './styles'
|
|
4
5
|
|
|
5
|
-
export type TextProps<T extends ElementType> =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
export type TextProps<T extends ElementType> = ComponentPropsWithoutRef<T> &
|
|
7
|
+
ComponentVariants<typeof TextPresets> & {
|
|
8
|
+
component?: T
|
|
9
|
+
text: string
|
|
10
|
+
styles?: StylesOf<TextComposition>
|
|
11
|
+
msg?: string
|
|
12
|
+
debugName?: string
|
|
13
|
+
debounce?: number
|
|
14
|
+
pressDisabled?: boolean
|
|
15
|
+
onPress?: (event: React.MouseEventHandler<T>) => void
|
|
16
|
+
animated?: boolean
|
|
17
|
+
animatedProps?: Partial<MotionProps>
|
|
18
|
+
}
|
|
@@ -25,6 +25,7 @@ import { StylesOf, HTMLProps, ComponentWithDefaultProps } from '../../types/util
|
|
|
25
25
|
import { InputBase, InputBaseProps, selectInputBaseProps } from '../InputBase'
|
|
26
26
|
import { TextInputPresets } from './styles'
|
|
27
27
|
import { getMaskInputProps, TextInputMaskingProps } from './mask'
|
|
28
|
+
import { getTestId } from '../../lib'
|
|
28
29
|
|
|
29
30
|
export * from './styles'
|
|
30
31
|
export * from './mask'
|
|
@@ -201,6 +202,8 @@ export const TextInputComponent = forwardRef<InputRef, TextInputProps>((props, i
|
|
|
201
202
|
|
|
202
203
|
const inputBaseAction = isPressable ? 'onPress' : 'onClick'
|
|
203
204
|
|
|
205
|
+
const testId = getTestId(others)
|
|
206
|
+
|
|
204
207
|
return (
|
|
205
208
|
<InputBase
|
|
206
209
|
innerWrapper={isPressable ? Touchable : undefined}
|
|
@@ -262,6 +265,7 @@ export const TextInputComponent = forwardRef<InputRef, TextInputProps>((props, i
|
|
|
262
265
|
]}
|
|
263
266
|
{...maskProps}
|
|
264
267
|
ref={innerInputRef}
|
|
268
|
+
data-testid={testId}
|
|
265
269
|
/>
|
|
266
270
|
</InputBase>
|
|
267
271
|
)
|
|
@@ -47,6 +47,7 @@ export type TooltipProps = PrimitiveTooltipProps & TooltipComponentProps & {
|
|
|
47
47
|
onHover?: (hoverType: 'enter' | 'leave', value: boolean) => void
|
|
48
48
|
onPress?: (value: boolean) => void
|
|
49
49
|
children?: React.ReactNode
|
|
50
|
+
style?: React.CSSProperties
|
|
50
51
|
} & ComponentVariants<typeof TooltipPresets> & ComponentCommonProps
|
|
51
52
|
|
|
52
53
|
const defaultProps: Partial<TooltipProps> = {
|
|
@@ -91,6 +92,7 @@ export const Tooltip: ComponentWithDefaultProps<TooltipProps> = (props: TooltipP
|
|
|
91
92
|
responsiveVariants = {},
|
|
92
93
|
styles = {},
|
|
93
94
|
closeOnClickOutside,
|
|
95
|
+
style,
|
|
94
96
|
...rest
|
|
95
97
|
} = allProps
|
|
96
98
|
|
|
@@ -105,7 +107,7 @@ export const Tooltip: ComponentWithDefaultProps<TooltipProps> = (props: TooltipP
|
|
|
105
107
|
const [visible, toggle] = hasStateProps ? [_visible, _toggle] : useState(false)
|
|
106
108
|
|
|
107
109
|
const tooltipDirectionStyle = React.useMemo(() => {
|
|
108
|
-
return side ? variantsStyles[`
|
|
110
|
+
return side ? variantsStyles[`content:${side}`] : variantsStyles.content
|
|
109
111
|
}, [side, variantsStyles])
|
|
110
112
|
|
|
111
113
|
function handleToggle(_value: boolean, isToggle = true) {
|
|
@@ -161,6 +163,7 @@ export const Tooltip: ComponentWithDefaultProps<TooltipProps> = (props: TooltipP
|
|
|
161
163
|
open={visible}
|
|
162
164
|
onOpenChange={onOpenChange}
|
|
163
165
|
{...rest}
|
|
166
|
+
css={[variantsStyles.wrapper, style]}
|
|
164
167
|
>
|
|
165
168
|
<TooltipTrigger
|
|
166
169
|
onClick={_onPress}
|
|
@@ -169,13 +172,18 @@ export const Tooltip: ComponentWithDefaultProps<TooltipProps> = (props: TooltipP
|
|
|
169
172
|
asChild
|
|
170
173
|
ref={triggerRef}
|
|
171
174
|
{...triggerProps}
|
|
175
|
+
style={variantsStyles.triggerWrapper}
|
|
172
176
|
>
|
|
173
|
-
<TriggerWrapper
|
|
177
|
+
<TriggerWrapper
|
|
178
|
+
{...allProps as any}
|
|
179
|
+
{...triggerWrapperProps}
|
|
180
|
+
style={variantsStyles.triggerInnerWrapper}
|
|
181
|
+
>
|
|
174
182
|
{children}
|
|
175
183
|
</TriggerWrapper>
|
|
176
184
|
</TooltipTrigger>
|
|
177
185
|
<TooltipPortal {...portalProps}>
|
|
178
|
-
<TooltipContent ref={contentRef} css={[tooltipDirectionStyle, variantsStyles.
|
|
186
|
+
<TooltipContent ref={contentRef} css={[tooltipDirectionStyle, variantsStyles.content]} sideOffset={2} side={side} {...contentProps}>
|
|
179
187
|
{
|
|
180
188
|
TypeGuards.isFunction(Content)
|
|
181
189
|
? <Content
|
|
@@ -186,7 +194,7 @@ export const Tooltip: ComponentWithDefaultProps<TooltipProps> = (props: TooltipP
|
|
|
186
194
|
/>
|
|
187
195
|
: Content
|
|
188
196
|
}
|
|
189
|
-
<TooltipArrow {...arrowProps} />
|
|
197
|
+
<TooltipArrow {...arrowProps} style={variantsStyles.arrow} />
|
|
190
198
|
</TooltipContent>
|
|
191
199
|
</TooltipPortal>
|
|
192
200
|
</TooltipWrapper>
|
|
@@ -2,9 +2,14 @@ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
|
2
2
|
|
|
3
3
|
export type TooltipSide = 'left' | 'right' | 'bottom' | 'top'
|
|
4
4
|
export type TooltipState = 'delayed-open' | 'closed' | 'instant-open' | 'disabled'
|
|
5
|
-
export type TooltipParts =
|
|
5
|
+
export type TooltipParts =
|
|
6
|
+
'wrapper' |
|
|
7
|
+
'arrow' |
|
|
8
|
+
'content' |
|
|
9
|
+
'triggerWrapper' |
|
|
10
|
+
'triggerInnerWrapper'
|
|
6
11
|
|
|
7
|
-
export type TooltipComposition = `
|
|
12
|
+
export type TooltipComposition = `content:${TooltipSide}` | TooltipParts
|
|
8
13
|
|
|
9
14
|
const createTooltipStyle = createDefaultVariantFactory<TooltipComposition>()
|
|
10
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyFunction, ComponentVariants, onMount, TypeGuards, useCodeleapContext, useDefaultComponentStyle } from '@codeleap/common'
|
|
2
2
|
import React, { ComponentPropsWithRef, ElementType, forwardRef } from 'react'
|
|
3
|
-
import { stopPropagation } from '../../lib'
|
|
3
|
+
import { getTestId, stopPropagation } from '../../lib'
|
|
4
4
|
import { View } from '../View'
|
|
5
5
|
import { TouchableComposition, TouchablePresets } from './styles'
|
|
6
6
|
import { CSSInterpolation } from '@emotion/css'
|
|
@@ -147,6 +147,8 @@ export const TouchableCP = <T extends NativeHTMLElement = 'button'>(
|
|
|
147
147
|
style,
|
|
148
148
|
]), [variantStyles, disabled, style])
|
|
149
149
|
|
|
150
|
+
const testId = getTestId(mergedProps)
|
|
151
|
+
|
|
150
152
|
return (
|
|
151
153
|
<View
|
|
152
154
|
component={Component || 'button'}
|
|
@@ -156,6 +158,7 @@ export const TouchableCP = <T extends NativeHTMLElement = 'button'>(
|
|
|
156
158
|
onKeyDown={handleClick}
|
|
157
159
|
ref={ref}
|
|
158
160
|
css={_styles}
|
|
161
|
+
data-testid={testId}
|
|
159
162
|
/>
|
|
160
163
|
)
|
|
161
164
|
}
|
|
@@ -1,49 +1,25 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx, CSSObject } from '@emotion/react'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
useDefaultComponentStyle,
|
|
6
|
-
useCodeleapContext,
|
|
7
|
-
useMemo,
|
|
8
|
-
BreakpointPlaceholder,
|
|
9
|
-
BaseViewProps,
|
|
10
|
-
|
|
11
|
-
TypeGuards,
|
|
12
|
-
} from '@codeleap/common'
|
|
13
|
-
import {
|
|
14
|
-
forwardRef,
|
|
15
|
-
Ref,
|
|
16
|
-
} from 'react'
|
|
3
|
+
import { useDefaultComponentStyle, useCodeleapContext, useMemo, TypeGuards } from '@codeleap/common'
|
|
4
|
+
import { forwardRef, Ref } from 'react'
|
|
17
5
|
import { ViewPresets } from './styles'
|
|
18
6
|
import { useMediaQuery } from '../../lib/hooks'
|
|
19
|
-
import {
|
|
7
|
+
import { NativeHTMLElement } from '../../types'
|
|
8
|
+
import { motion } from 'framer-motion'
|
|
9
|
+
import { ViewProps } from './types'
|
|
10
|
+
import { getTestId } from '../../lib'
|
|
20
11
|
|
|
21
12
|
export * from './styles'
|
|
22
|
-
|
|
23
|
-
export type ViewProps<T extends NativeHTMLElement> =
|
|
24
|
-
HTMLProps<T> &
|
|
25
|
-
ComponentVariants<typeof ViewPresets> &
|
|
26
|
-
{
|
|
27
|
-
component?: T
|
|
28
|
-
scroll?: boolean
|
|
29
|
-
debugName?: string
|
|
30
|
-
debug?: boolean
|
|
31
|
-
is?: BreakpointPlaceholder
|
|
32
|
-
not?: BreakpointPlaceholder
|
|
33
|
-
up?: BreakpointPlaceholder
|
|
34
|
-
down?: BreakpointPlaceholder
|
|
35
|
-
onHover?: (isMouseOverElement: boolean) => void
|
|
36
|
-
} & BaseViewProps
|
|
13
|
+
export * from './types'
|
|
37
14
|
|
|
38
15
|
export const ViewCP = (
|
|
39
16
|
viewProps: ViewProps<'div'>,
|
|
40
17
|
ref: Ref<any>,
|
|
41
18
|
) => {
|
|
42
|
-
|
|
43
19
|
const {
|
|
44
20
|
responsiveVariants = {},
|
|
45
21
|
variants = [],
|
|
46
|
-
component
|
|
22
|
+
component = 'div',
|
|
47
23
|
children,
|
|
48
24
|
is,
|
|
49
25
|
not,
|
|
@@ -54,10 +30,14 @@ export const ViewCP = (
|
|
|
54
30
|
scroll = false,
|
|
55
31
|
debug = false,
|
|
56
32
|
style,
|
|
33
|
+
animated = false,
|
|
34
|
+
animatedProps = {},
|
|
57
35
|
css = [],
|
|
58
36
|
...props
|
|
59
37
|
} = viewProps
|
|
60
38
|
|
|
39
|
+
const Component = animated ? (motion?.[component] || motion.div) : (component || 'div')
|
|
40
|
+
|
|
61
41
|
const variantStyles = useDefaultComponentStyle<'u:View', typeof ViewPresets>('u:View', {
|
|
62
42
|
responsiveVariants,
|
|
63
43
|
variants,
|
|
@@ -101,12 +81,16 @@ export const ViewCP = (
|
|
|
101
81
|
logger.log(debugName, { componentStyles, platformMediaQuery, matches })
|
|
102
82
|
}
|
|
103
83
|
|
|
84
|
+
const testId = getTestId(viewProps)
|
|
85
|
+
|
|
104
86
|
return (
|
|
105
87
|
<Component
|
|
106
88
|
css={componentStyles}
|
|
107
89
|
ref={ref}
|
|
108
90
|
{...onHoverProps}
|
|
109
91
|
{...props}
|
|
92
|
+
{...animatedProps}
|
|
93
|
+
data-testid={testId}
|
|
110
94
|
>
|
|
111
95
|
{children}
|
|
112
96
|
</Component>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseViewProps, BreakpointPlaceholder, ComponentVariants } from '@codeleap/common'
|
|
2
|
+
import { HTMLProps, NativeHTMLElement } from '../../types'
|
|
3
|
+
import { AnimationProps, MotionProps } from 'framer-motion'
|
|
4
|
+
import { ViewPresets } from './styles'
|
|
5
|
+
|
|
6
|
+
export type ViewProps<T extends NativeHTMLElement> =
|
|
7
|
+
HTMLProps<T> &
|
|
8
|
+
ComponentVariants<typeof ViewPresets> &
|
|
9
|
+
Omit<AnimationProps, 'variants'> &
|
|
10
|
+
{
|
|
11
|
+
component?: T
|
|
12
|
+
scroll?: boolean
|
|
13
|
+
debugName?: string
|
|
14
|
+
debug?: boolean
|
|
15
|
+
is?: BreakpointPlaceholder
|
|
16
|
+
not?: BreakpointPlaceholder
|
|
17
|
+
up?: BreakpointPlaceholder
|
|
18
|
+
down?: BreakpointPlaceholder
|
|
19
|
+
onHover?: (isMouseOverElement: boolean) => void
|
|
20
|
+
animated?: boolean
|
|
21
|
+
animatedProps?: Partial<MotionProps>
|
|
22
|
+
} & BaseViewProps
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './types/utility'
|
|
|
5
5
|
export * from './lib/useSearchParams'
|
|
6
6
|
export * from './lib/useBreakpointMatch'
|
|
7
7
|
export * from './lib/usePopState'
|
|
8
|
+
export * from './lib/useAnimatedStyle'
|
|
8
9
|
export { default as Toast } from './lib/Toast'
|
|
9
10
|
export { CreateOSAlert, useGlobalAlertComponent, AlertOutlet } from './lib/OSAlert'
|
|
10
11
|
export type { GlobalAlertComponentProps, GlobalAlertType } from './lib/OSAlert'
|
package/src/lib/index.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useRef } from 'react'
|
|
2
|
+
import { onUpdate, useState } from '@codeleap/common'
|
|
3
|
+
import { AnimationProps } from 'framer-motion'
|
|
4
|
+
|
|
5
|
+
type UpdaterReturn = Omit<AnimationProps['animate'], 'transition'> & {
|
|
6
|
+
transition: AnimationProps['transition']
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type UseAnimatedStyleReturn = Pick<AnimationProps, 'animate' | 'initial' | 'transition'>
|
|
10
|
+
|
|
11
|
+
export const useAnimatedStyle = (updater: () => UpdaterReturn, deps: Array<any>): UseAnimatedStyleReturn => {
|
|
12
|
+
const initialStyle = updater()
|
|
13
|
+
|
|
14
|
+
const [animatedStyle, setAnimatedStyle] = useState(initialStyle)
|
|
15
|
+
const transition = useRef(initialStyle.transition)
|
|
16
|
+
|
|
17
|
+
onUpdate(() => {
|
|
18
|
+
const animatedStyleUpdated = updater()
|
|
19
|
+
|
|
20
|
+
setAnimatedStyle(animatedStyleUpdated)
|
|
21
|
+
}, deps)
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
animate: animatedStyle,
|
|
25
|
+
transition: transition.current,
|
|
26
|
+
initial: false,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -4,7 +4,7 @@ import { useMediaQuery } from './hooks'
|
|
|
4
4
|
|
|
5
5
|
export type BreakpointsMatch<T extends string = string> = Record<T, any>
|
|
6
6
|
|
|
7
|
-
export function useBreakpointMatch<T extends string = string>(values: BreakpointsMatch<T
|
|
7
|
+
export function useBreakpointMatch<T extends string = string>(values: Partial<BreakpointsMatch<T>>) {
|
|
8
8
|
const { Theme } = useCodeleapContext()
|
|
9
9
|
|
|
10
10
|
const themeBreakpoints: Record<string, number> = Theme?.breakpoints
|
package/src/lib/utils/index.ts
CHANGED