react-native-tuto-showcase 1.0.4 → 1.0.5

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,6 +1,18 @@
1
1
  import React from 'react';
2
2
  import { AnyShape } from '../types/shapes';
3
- export default function LottieAboveTarget({ shapes, lottie, }: {
3
+ export type LottiePlacement = 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'center';
4
+ type Offset = {
5
+ dx?: number;
6
+ dy?: number;
7
+ };
8
+ type Props = {
4
9
  shapes: AnyShape[];
5
10
  lottie: React.ReactElement<any>;
6
- }): import("react/jsx-runtime").JSX.Element | null;
11
+ overlayWidth: number;
12
+ overlayHeight: number;
13
+ placement?: LottiePlacement;
14
+ offset?: Offset;
15
+ };
16
+ export default function LottieAboveTarget({ shapes, lottie, overlayWidth, overlayHeight, placement, // 👈 الديفولت: فوق في النص بالنسبة للشاشة كلها
17
+ offset, }: Props): import("react/jsx-runtime").JSX.Element | null;
18
+ export {};
@@ -1,17 +1,56 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { View, StyleSheet } from 'react-native';
4
- export default function LottieAboveTarget({ shapes, lottie, }) {
5
- if (!lottie || shapes.length === 0)
4
+ const PADDING_H = 24;
5
+ const PADDING_V = 32;
6
+ export default function LottieAboveTarget({ shapes, lottie, overlayWidth, overlayHeight, placement = 'top-center', // 👈 الديفولت: فوق في النص بالنسبة للشاشة كلها
7
+ offset, }) {
8
+ if (!lottie)
6
9
  return null;
7
- const focus = shapes[shapes.length - 1];
8
10
  const layout = StyleSheet.flatten(lottie.props?.style) || {};
9
11
  const lw = layout.width ?? 100;
10
12
  const lh = layout.height ?? 100;
11
- const cx = focus.cx;
12
- const topOfHole = focus.type === 'circle' ? focus.cy - focus.r : focus.y;
13
- const top = topOfHole - lh + 50;
14
- const left = cx - lw / 2;
13
+ let top = 0;
14
+ let left = 0;
15
+ switch (placement) {
16
+ case 'top-left':
17
+ top = PADDING_V;
18
+ left = PADDING_H;
19
+ break;
20
+ case 'top-right':
21
+ top = PADDING_V;
22
+ left = overlayWidth - lw - PADDING_H;
23
+ break;
24
+ case 'top-center':
25
+ top = PADDING_V;
26
+ left = (overlayWidth - lw) / 2;
27
+ break;
28
+ case 'bottom-left':
29
+ top = overlayHeight - lh - PADDING_V;
30
+ left = PADDING_H;
31
+ break;
32
+ case 'bottom-right':
33
+ top = overlayHeight - lh - PADDING_V;
34
+ left = overlayWidth - lw - PADDING_H;
35
+ break;
36
+ case 'bottom-center':
37
+ top = overlayHeight - lh - PADDING_V;
38
+ left = (overlayWidth - lw) / 2;
39
+ break;
40
+ case 'center':
41
+ top = (overlayHeight - lh) / 2;
42
+ left = (overlayWidth - lw) / 2;
43
+ break;
44
+ default:
45
+ top = PADDING_V;
46
+ left = (overlayWidth - lw) / 2;
47
+ break;
48
+ }
49
+ // ✅ اختياري: إزاحة إضافية
50
+ if (offset?.dx)
51
+ left += offset.dx;
52
+ if (offset?.dy)
53
+ top += offset.dy;
15
54
  return (_jsx(View, { pointerEvents: "none", style: [
16
55
  styles.container,
17
56
  { top, left, width: lw, height: lh },
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { LottiePlacement } from './components/LottieAboveTarget';
2
3
  export type TutoShowcaseHandle = {
3
4
  on: (r: any) => any;
4
5
  show: () => void;
@@ -7,5 +8,20 @@ export type TutoShowcaseHandle = {
7
8
  isShowOnce: (key: string) => boolean;
8
9
  resetShowOnce: (key: string) => void;
9
10
  };
10
- declare const TutoShowcase: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<TutoShowcaseHandle>>;
11
+ type TutoShowcaseProps = {
12
+ title?: React.ReactNode;
13
+ description?: React.ReactNode;
14
+ buttonText?: string;
15
+ buttonTextStyle?: any;
16
+ buttonContainerStyle?: any;
17
+ overlayBackgroundColor?: string;
18
+ onGotIt?: () => void;
19
+ lottie?: React.ReactElement<any> | null;
20
+ lottiePlacement?: LottiePlacement;
21
+ lottieOffset?: {
22
+ dx?: number;
23
+ dy?: number;
24
+ };
25
+ };
26
+ declare const TutoShowcase: React.ForwardRefExoticComponent<TutoShowcaseProps & React.RefAttributes<TutoShowcaseHandle>>;
11
27
  export default TutoShowcase;
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ import { usePulseAnimation } from './hooks/usePulseAnimation';
11
11
  import { buildActionsFactory } from './helpers/buildActions';
12
12
  import { useContentPosition } from './hooks/useContentPosition';
13
13
  const DEFAULT_BG = 'rgba(0,0,0,0.78)';
14
- const TutoShowcase = forwardRef(function Tuto({ title, description, buttonText = 'GOT IT', buttonTextStyle, buttonContainerStyle, overlayBackgroundColor, onGotIt, lottie, }, ref) {
14
+ const TutoShowcase = forwardRef(function Tuto({ title, description, buttonText = 'GOT IT', buttonTextStyle, buttonContainerStyle, overlayBackgroundColor, onGotIt, lottie, lottiePlacement, // 👈 خدناه من props
15
+ lottieOffset, }, ref) {
15
16
  // -------- Hooks يجب أن تكون في الأعلى وبنفس الترتيب دائماً --------
16
17
  const [visible, setVisible] = useState(false);
17
18
  const [bgColor, setBgColor] = useState(overlayBackgroundColor || DEFAULT_BG);
@@ -84,7 +85,7 @@ const TutoShowcase = forwardRef(function Tuto({ title, description, buttonText =
84
85
  // ✅ الشرط هنا بعد كل الـ hooks
85
86
  if (!visible)
86
87
  return null;
87
- return (_jsx(Modal, { visible: true, transparent: true, animationType: "fade", children: _jsx(TouchableWithoutFeedback, { onPress: onOverlayPress, children: _jsxs(View, { ref: rootRef, onLayout: onLayout, style: [StyleSheet.absoluteFill, { direction: 'ltr' }], children: [_jsx(Overlay, { width: width, height: height, shapes: shapes, bgColor: bgColor, spotScale: spotScale, spotOpacity: spotOpacity }), lottie && _jsx(LottieAboveTarget, { shapes: shapes, lottie: lottie }), (title || description) && (_jsx(ContentSection, { title: title, description: description, buttonText: buttonText, buttonTextStyle: buttonTextStyle, buttonContainerStyle: buttonContainerStyle, coords: coords, onPress: () => {
88
+ return (_jsx(Modal, { visible: true, transparent: true, animationType: "fade", children: _jsx(TouchableWithoutFeedback, { onPress: onOverlayPress, children: _jsxs(View, { ref: rootRef, onLayout: onLayout, style: [StyleSheet.absoluteFill, { direction: 'ltr' }], children: [_jsx(Overlay, { width: width, height: height, shapes: shapes, bgColor: bgColor, spotScale: spotScale, spotOpacity: spotOpacity }), lottie && (_jsx(LottieAboveTarget, { shapes: shapes, lottie: lottie, overlayWidth: width, overlayHeight: height, placement: lottiePlacement, offset: lottieOffset })), (title || description) && (_jsx(ContentSection, { title: title, description: description, buttonText: buttonText, buttonTextStyle: buttonTextStyle, buttonContainerStyle: buttonContainerStyle, coords: coords, onPress: () => {
88
89
  onGotIt?.();
89
90
  dismiss();
90
91
  } })), _jsx(GestureHints, { hints: hints })] }) }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tuto-showcase",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Customizable tutorial / spotlight overlay for React Native (onboarding, feature tours, coachmarks).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,18 +26,18 @@
26
26
  ],
27
27
  "author": "Ahmed Mohamed Ali Ali Hegazy",
28
28
  "license": "MIT",
29
+ "packageManager": "yarn@3.6.4+sha512.e70835d4d6d62c07be76b3c1529cb640c7443f0fe434ef4b6478a5a399218cbaf1511b396b3c56eb03bc86424cff2320f6167ad2fde273aa0df6e60b7754029f",
29
30
  "peerDependencies": {
31
+ "@react-native-async-storage/async-storage": ">=1.17.0",
30
32
  "react": ">=18.0.0",
31
- "react-native": ">=0.72.0"
32
- },
33
- "dependencies": {
34
- "@react-native-async-storage/async-storage": "^1.23.0",
35
- "react-native-svg": "^13.14.0"
33
+ "react-native": ">=0.72.0",
34
+ "react-native-svg": ">=13.0.0"
36
35
  },
37
- "packageManager": "yarn@3.6.4+sha512.e70835d4d6d62c07be76b3c1529cb640c7443f0fe434ef4b6478a5a399218cbaf1511b396b3c56eb03bc86424cff2320f6167ad2fde273aa0df6e60b7754029f",
38
36
  "devDependencies": {
37
+ "@react-native-async-storage/async-storage": "^1.23.0",
39
38
  "@types/react": "^19.2.7",
40
39
  "@types/react-native": "^0.72.8",
40
+ "react-native-svg": "^13.14.0",
41
41
  "typescript": "^5.9.3"
42
42
  }
43
43
  }