react-native-ui-lib 7.46.1 → 7.46.2-snapshot.7306

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.46.1",
3
+ "version": "7.46.2-snapshot.7306",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -10,4 +10,5 @@ export { default as useScrollToItem } from './useScrollToItem';
10
10
  export { default as useScrollTo } from './useScrollTo';
11
11
  export { default as useThemeProps } from './useThemeProps';
12
12
  export { default as useDebounce } from './useDebounce';
13
+ export { default as useKeyboardHeight } from './useKeyboardHeight';
13
14
  export * from './useScrollTo';
@@ -10,4 +10,5 @@ export { default as useScrollToItem } from "./useScrollToItem";
10
10
  export { default as useScrollTo } from "./useScrollTo";
11
11
  export { default as useThemeProps } from "./useThemeProps";
12
12
  export { default as useDebounce } from "./useDebounce";
13
+ export { default as useKeyboardHeight } from "./useKeyboardHeight";
13
14
  export * from "./useScrollTo";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook that tracks keyboard height and provides real-time updates
3
+ */
4
+ declare const useKeyboardHeight: () => number;
5
+ export default useKeyboardHeight;
@@ -0,0 +1,23 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Keyboard } from 'react-native';
3
+
4
+ /**
5
+ * Hook that tracks keyboard height and provides real-time updates
6
+ */
7
+ const useKeyboardHeight = () => {
8
+ const [keyboardHeight, setKeyboardHeight] = useState(0);
9
+ useEffect(() => {
10
+ const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
11
+ setKeyboardHeight(0);
12
+ });
13
+ const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', e => {
14
+ setKeyboardHeight(e.endCoordinates.height);
15
+ });
16
+ return () => {
17
+ keyboardDidHideListener.remove();
18
+ keyboardDidShowListener.remove();
19
+ };
20
+ }, []);
21
+ return keyboardHeight;
22
+ };
23
+ export default useKeyboardHeight;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { BorderGradientProps } from './types';
3
+ declare const BorderGradient: (props: BorderGradientProps) => React.JSX.Element | null;
4
+ export default BorderGradient;
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { LinearGradientPackage } from "../../optionalDependencies";
3
+ const LinearGradient = LinearGradientPackage?.default;
4
+ import View from "../../components/view";
5
+ import Spacings from "../../style/spacings";
6
+ import Colors from "../../style/colors";
7
+ import useAngleTransform from "./useAngleTransform";
8
+ const BorderGradient = props => {
9
+ const {
10
+ colors,
11
+ borderWidth = Spacings.s1,
12
+ borderRadius,
13
+ children,
14
+ width,
15
+ height,
16
+ angle,
17
+ ...others
18
+ } = props;
19
+ const innerWidth = width ? width - borderWidth * 2 : undefined;
20
+ const innerHeight = height ? height - borderWidth * 2 : undefined;
21
+ const {
22
+ start,
23
+ end
24
+ } = useAngleTransform({
25
+ angle
26
+ });
27
+ if (!LinearGradient) {
28
+ return null;
29
+ }
30
+ return <View width={width} height={height}>
31
+ <LinearGradient colors={colors} start={start} end={end} style={{
32
+ borderRadius
33
+ }}>
34
+ <View bg-white width={innerWidth} height={innerHeight} style={{
35
+ margin: borderWidth,
36
+ borderRadius,
37
+ borderWidth: 0,
38
+ borderColor: Colors.transparent
39
+ }} {...others}>
40
+ {children}
41
+ </View>
42
+ </LinearGradient>
43
+ </View>;
44
+ };
45
+ export default BorderGradient;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { CircleGradientProps } from './types';
3
+ declare const CircleGradient: (props: CircleGradientProps) => React.JSX.Element | null;
4
+ export default CircleGradient;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { LinearGradientPackage } from "../../optionalDependencies";
3
+ const LinearGradient = LinearGradientPackage?.default;
4
+ import View from "../../components/view";
5
+ import useAngleTransform from "./useAngleTransform";
6
+ const CircleGradient = props => {
7
+ const {
8
+ colors,
9
+ radius,
10
+ angle,
11
+ children,
12
+ ...others
13
+ } = props;
14
+ const internalDiameter = radius ? radius * 2 : undefined;
15
+ const {
16
+ start,
17
+ end
18
+ } = useAngleTransform({
19
+ angle
20
+ });
21
+ if (!LinearGradient) {
22
+ return null;
23
+ }
24
+ return <View width={internalDiameter} height={internalDiameter} style={{
25
+ borderRadius: 999,
26
+ overflow: 'hidden'
27
+ }}>
28
+ <LinearGradient colors={colors} start={start} end={end}>
29
+ <View width={internalDiameter} height={internalDiameter} {...others}>
30
+ {children}
31
+ </View>
32
+ </LinearGradient>
33
+ </View>;
34
+ };
35
+ export default CircleGradient;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { RectangleGradientProps } from './types';
3
+ declare const RectangleGradient: (props: RectangleGradientProps) => React.JSX.Element | null;
4
+ export default RectangleGradient;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { LinearGradientPackage } from "../../optionalDependencies";
3
+ const LinearGradient = LinearGradientPackage?.default;
4
+ import View from "../../components/view";
5
+ import useAngleTransform from "./useAngleTransform";
6
+ const RectangleGradient = props => {
7
+ const {
8
+ colors,
9
+ width,
10
+ height,
11
+ angle,
12
+ children,
13
+ ...others
14
+ } = props;
15
+ const {
16
+ start,
17
+ end
18
+ } = useAngleTransform({
19
+ angle
20
+ });
21
+ if (!LinearGradient) {
22
+ return null;
23
+ }
24
+ return <View width={width} height={height}>
25
+ <LinearGradient colors={colors} start={start} end={end}>
26
+ <View width={width} height={height} {...others}>
27
+ {children}
28
+ </View>
29
+ </LinearGradient>
30
+ </View>;
31
+ };
32
+ export default RectangleGradient;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { GradientProps } from './types';
3
+ export { GradientProps };
4
+ declare const Gradient: (props: GradientProps) => React.JSX.Element | null;
5
+ export default Gradient;
@@ -0,0 +1,31 @@
1
+ import React, { useEffect } from 'react';
2
+ import { LinearGradientPackage } from "../../optionalDependencies";
3
+ const LinearGradient = LinearGradientPackage?.default;
4
+ import { LogService } from "../../services";
5
+ import { GradientProps } from "./types";
6
+ import RectangleGradient from "./RectangleGradient";
7
+ import CircleGradient from "./CircleGradient";
8
+ import BorderGradient from "./BorderGradient";
9
+ export { GradientProps };
10
+ const Gradient = props => {
11
+ const {
12
+ type = 'rectangle',
13
+ ...others
14
+ } = props;
15
+ useEffect(() => {
16
+ if (LinearGradient === undefined) {
17
+ LogService.error(`RNUILib Gradient requires installing "react-native-linear-gradient" dependency`);
18
+ }
19
+ }, []);
20
+ switch (type) {
21
+ case 'rectangle':
22
+ return <RectangleGradient {...others} />;
23
+ case 'circle':
24
+ return <CircleGradient {...others} />;
25
+ case 'border':
26
+ return <BorderGradient {...others} />;
27
+ default:
28
+ return null;
29
+ }
30
+ };
31
+ export default Gradient;
@@ -0,0 +1,26 @@
1
+ import type { LinearGradientProps } from 'react-native-linear-gradient';
2
+ type CommonGradientProps = Pick<LinearGradientProps, 'colors' | 'children'> & {
3
+ angle?: number;
4
+ center?: boolean;
5
+ centerH?: boolean;
6
+ centerV?: boolean;
7
+ };
8
+ export type GradientProps = ({
9
+ type: 'rectangle';
10
+ } & RectangleGradientProps) | ({
11
+ type: 'circle';
12
+ } & CircleGradientProps) | ({
13
+ type: 'border';
14
+ } & BorderGradientProps);
15
+ export type RectangleGradientProps = CommonGradientProps & {
16
+ width?: number;
17
+ height?: number;
18
+ };
19
+ export type CircleGradientProps = CommonGradientProps & {
20
+ radius: number;
21
+ };
22
+ export type BorderGradientProps = RectangleGradientProps & {
23
+ borderWidth?: number;
24
+ borderRadius?: number;
25
+ };
26
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ declare function getStartEndFromAngle(angle?: number): {
2
+ start: {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ end: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ };
11
+ export declare const _forTesting: {
12
+ getStartEndFromAngle: typeof getStartEndFromAngle;
13
+ };
14
+ export type AngleTransformProps = {
15
+ angle?: number;
16
+ };
17
+ declare const useAngleTransform: (props: AngleTransformProps) => {
18
+ start: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ end: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ };
27
+ export default useAngleTransform;
@@ -0,0 +1,72 @@
1
+ import { useMemo } from 'react';
2
+ const EPSILON = 1e-12;
3
+ function getStartEndFromAngle(angle = 0) {
4
+ // Normalize angle to [0, 360)
5
+ let a = angle % 360;
6
+ if (a < 0) {
7
+ a += 360;
8
+ }
9
+ const rad = a * Math.PI / 180;
10
+
11
+ // Direction vector where 0deg points up, 90deg right, etc.
12
+ const vx = Math.sin(rad);
13
+ const vy = -Math.cos(rad);
14
+
15
+ // Distance from center (0.5,0.5) to box edge along v
16
+ const denomX = Math.abs(vx) > EPSILON ? 0.5 / Math.abs(vx) : Number.POSITIVE_INFINITY;
17
+ const denomY = Math.abs(vy) > EPSILON ? 0.5 / Math.abs(vy) : Number.POSITIVE_INFINITY;
18
+ const t = Math.min(denomX, denomY);
19
+ const cx = 0.5;
20
+ const cy = 0.5;
21
+ const end = {
22
+ x: cx + vx * t,
23
+ y: cy + vy * t
24
+ };
25
+ const start = {
26
+ x: cx - vx * t,
27
+ y: cy - vy * t
28
+ };
29
+
30
+ // Quantize to avoid tiny floating errors for canonical angles (0, 45, 90, ...).
31
+ const quantize = v => {
32
+ if (Math.abs(v - 0) < EPSILON) {
33
+ return 0;
34
+ }
35
+ if (Math.abs(v - 0.5) < EPSILON) {
36
+ return 0.5;
37
+ }
38
+ if (Math.abs(v - 1) < EPSILON) {
39
+ return 1;
40
+ }
41
+ // Clamp just in case of tiny over/underflows
42
+ if (v < 0) {
43
+ return 0;
44
+ }
45
+ if (v > 1) {
46
+ return 1;
47
+ }
48
+ return v;
49
+ };
50
+ return {
51
+ start: {
52
+ x: quantize(start.x),
53
+ y: quantize(start.y)
54
+ },
55
+ end: {
56
+ x: quantize(end.x),
57
+ y: quantize(end.y)
58
+ }
59
+ };
60
+ }
61
+ export const _forTesting = {
62
+ getStartEndFromAngle
63
+ }; // exporting private functions for testing only
64
+
65
+ const useAngleTransform = props => {
66
+ const {
67
+ angle
68
+ } = props;
69
+ const startEnd = useMemo(() => getStartEndFromAngle(angle), [angle]);
70
+ return startEnd;
71
+ };
72
+ export default useAngleTransform;
@@ -8,3 +8,4 @@ export { default as Slider, SliderRef, SliderProps } from './slider';
8
8
  export { default as Dialog, DialogProps, DialogHeaderProps, DialogStatics, DialogImperativeMethods } from './dialog';
9
9
  export { default as ChipsInput, ChipsInputProps, ChipsInputChangeReason, ChipsInputChipProps } from '../components/chipsInput';
10
10
  export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from '../components/WheelPicker';
11
+ export { default as Gradient, GradientProps } from './gradient';
@@ -9,4 +9,5 @@ export { default as Slider, SliderRef, SliderProps } from "./slider";
9
9
  export { default as Dialog, DialogProps, DialogHeaderProps, DialogStatics, DialogImperativeMethods } from "./dialog";
10
10
  // TODO: delete exports after fully removing from private
11
11
  export { default as ChipsInput, ChipsInputProps, ChipsInputChangeReason, ChipsInputChipProps } from "../components/chipsInput";
12
- export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from "../components/WheelPicker";
12
+ export { default as WheelPicker, WheelPickerProps, WheelPickerItemProps, WheelPickerAlign, WheelPickerItemValue } from "../components/WheelPicker";
13
+ export { default as Gradient, GradientProps } from "./gradient";
@@ -1,2 +1,2 @@
1
- declare let LinearGradientPackage: any;
1
+ declare let LinearGradientPackage: typeof import('react-native-linear-gradient') | undefined;
2
2
  export default LinearGradientPackage;
@@ -7,6 +7,7 @@ export declare const BorderRadiusesLiterals: {
7
7
  br40: number;
8
8
  br50: number;
9
9
  br60: number;
10
+ br70: number;
10
11
  br90: number;
11
12
  br100: number;
12
13
  };
@@ -22,6 +23,7 @@ declare const borderRadiusesInstance: BorderRadiuses & {
22
23
  br40: number;
23
24
  br50: number;
24
25
  br60: number;
26
+ br70: number;
25
27
  br90: number;
26
28
  br100: number;
27
29
  };
@@ -13,6 +13,7 @@ export const BorderRadiusesLiterals /* : IBorderRadiusesLiterals */ = {
13
13
  br40: 12,
14
14
  br50: Constants.isIOS ? 15 : 16,
15
15
  br60: 20,
16
+ br70: 24,
16
17
  br90: 32,
17
18
  br100: 999
18
19
  };