flowboard-react 0.6.8 → 0.6.12

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.
Files changed (48) hide show
  1. package/README.md +16 -0
  2. package/lib/module/components/FlowboardFlow.js +24 -66
  3. package/lib/module/components/FlowboardFlow.js.map +1 -1
  4. package/lib/module/components/FlowboardRenderer.js +590 -196
  5. package/lib/module/components/FlowboardRenderer.js.map +1 -1
  6. package/lib/module/components/layout/stackOverlayModel.js +156 -0
  7. package/lib/module/components/layout/stackOverlayModel.js.map +1 -0
  8. package/lib/module/fonts/fontLoader.js +285 -0
  9. package/lib/module/fonts/fontLoader.js.map +1 -0
  10. package/lib/module/fonts/fontResolver.js +38 -0
  11. package/lib/module/fonts/fontResolver.js.map +1 -0
  12. package/lib/module/fonts/google-fonts-meta.json +1 -0
  13. package/lib/module/fonts/googleFontCatalog.js +56 -0
  14. package/lib/module/fonts/googleFontCatalog.js.map +1 -0
  15. package/lib/module/fonts/googleFontLoader.js +101 -0
  16. package/lib/module/fonts/googleFontLoader.js.map +1 -0
  17. package/lib/module/fonts/googleFontsLoader.js +68 -0
  18. package/lib/module/fonts/googleFontsLoader.js.map +1 -0
  19. package/lib/module/index.js +2 -0
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/typescript/src/components/FlowboardFlow.d.ts.map +1 -1
  22. package/lib/typescript/src/components/FlowboardRenderer.d.ts +11 -4
  23. package/lib/typescript/src/components/FlowboardRenderer.d.ts.map +1 -1
  24. package/lib/typescript/src/components/layout/stackOverlayModel.d.ts +13 -0
  25. package/lib/typescript/src/components/layout/stackOverlayModel.d.ts.map +1 -0
  26. package/lib/typescript/src/fonts/fontLoader.d.ts +17 -0
  27. package/lib/typescript/src/fonts/fontLoader.d.ts.map +1 -0
  28. package/lib/typescript/src/fonts/fontResolver.d.ts +11 -0
  29. package/lib/typescript/src/fonts/fontResolver.d.ts.map +1 -0
  30. package/lib/typescript/src/fonts/googleFontCatalog.d.ts +4 -0
  31. package/lib/typescript/src/fonts/googleFontCatalog.d.ts.map +1 -0
  32. package/lib/typescript/src/fonts/googleFontLoader.d.ts +7 -0
  33. package/lib/typescript/src/fonts/googleFontLoader.d.ts.map +1 -0
  34. package/lib/typescript/src/fonts/googleFontsLoader.d.ts +18 -0
  35. package/lib/typescript/src/fonts/googleFontsLoader.d.ts.map +1 -0
  36. package/lib/typescript/src/index.d.ts +2 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -1
  38. package/package.json +25 -13
  39. package/src/components/FlowboardFlow.tsx +33 -82
  40. package/src/components/FlowboardRenderer.tsx +852 -210
  41. package/src/components/layout/stackOverlayModel.ts +185 -0
  42. package/src/fonts/fontLoader.ts +426 -0
  43. package/src/fonts/fontResolver.ts +69 -0
  44. package/src/fonts/google-fonts-meta.json +1 -0
  45. package/src/fonts/googleFontCatalog.ts +77 -0
  46. package/src/fonts/googleFontLoader.ts +136 -0
  47. package/src/fonts/googleFontsLoader.ts +124 -0
  48. package/src/index.tsx +13 -0
@@ -0,0 +1,18 @@
1
+ export type GoogleFontLoadRequest = {
2
+ family: string;
3
+ weight: number;
4
+ nativeFontName: string;
5
+ cacheKey: string;
6
+ };
7
+ export type GoogleFontProvider = {
8
+ loadFont: (request: GoogleFontLoadRequest) => Promise<boolean | string | void> | boolean | string | void;
9
+ };
10
+ export declare function resolveGoogleFontWeight(family: string, weight?: number | string): number;
11
+ export declare function resolveGoogleFontNativeName(family: string, weight?: number | string): string;
12
+ export declare function ensureGoogleFontLoaded(family: string, weight?: number | string): Promise<void>;
13
+ export declare function isGoogleFontLoaded(family: string, weight?: number | string): boolean;
14
+ export declare function getLoadedGoogleFontNativeName(family: string, weight?: number | string): string | undefined;
15
+ export declare function registerGoogleFontProvider(provider: GoogleFontProvider | null): void;
16
+ export declare function subscribeGoogleFontLoad(listener: () => void): () => void;
17
+ export declare function __resetGoogleFontsLoaderForTests(): void;
18
+ //# sourceMappingURL=googleFontsLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleFontsLoader.d.ts","sourceRoot":"","sources":["../../../../src/fonts/googleFontsLoader.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,CACR,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CACjE,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GACvB,MAAM,CAWR;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GACvB,MAAM,CASR;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GACvB,OAAO,CAST;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GACvB,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,GAClC,IAAI,CAgBN;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAExE;AAED,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD"}
@@ -1,6 +1,8 @@
1
1
  export { Flowboard } from './Flowboard';
2
2
  export { default as FlowboardProvider } from './FlowboardProvider';
3
3
  export { default as FlowboardFlow } from './components/FlowboardFlow';
4
+ export { ensureGoogleFontLoaded, registerFontResolver, resolveFontFamily, } from './fonts/googleFontLoader';
5
+ export { ensureGoogleFontLoaded as ensureGoogleNativeFontLoaded, getLoadedGoogleFontNativeName, isGoogleFontLoaded as isGoogleNativeFontLoaded, registerGoogleFontProvider, resolveGoogleFontNativeName, resolveGoogleFontWeight, } from './fonts/googleFontsLoader';
4
6
  export type { FlowboardContext, CustomScreenBuilder, CustomActionBuilder, OnboardingEndCallback, OnStepChangeCallback, FlowboardLaunchOptions, FlowboardLaunchByIdOptions, FlowboardFlowVersion, FlowboardData, } from './types/flowboard';
5
7
  export type { FlowboardFlowProps } from './components/FlowboardFlow';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,IAAI,4BAA4B,EACtD,6BAA6B,EAC7B,kBAAkB,IAAI,wBAAwB,EAC9C,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowboard-react",
3
- "version": "0.6.8",
3
+ "version": "0.6.12",
4
4
  "description": "Onboard your users with one click",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -99,20 +99,32 @@
99
99
  "typescript": "^5.9.2"
100
100
  },
101
101
  "peerDependencies": {
102
- "@react-native-async-storage/async-storage": ">= 1.24.0",
103
- "@react-native-masked-view/masked-view": ">= 0.3.2",
104
- "lottie-react-native": ">= 7.1.0",
102
+ "@react-native-async-storage/async-storage": "*",
103
+ "@react-native-masked-view/masked-view": "*",
104
+ "expo-font": "*",
105
+ "lottie-react-native": "*",
105
106
  "react": ">= 18.2.0",
106
107
  "react-native": ">= 0.71.0",
107
- "react-native-device-info": ">= 13.2.0",
108
- "react-native-get-random-values": ">= 1.11.0",
109
- "react-native-in-app-review": ">= 4.3.0",
110
- "react-native-linear-gradient": ">= 2.8.3",
111
- "react-native-pager-view": ">= 6.2.3",
112
- "react-native-permissions": ">= 4.1.5",
113
- "react-native-safe-area-context": ">= 5.0.0",
114
- "react-native-svg": ">= 15.10.1",
115
- "react-native-vector-icons": ">= 10.2.0"
108
+ "react-native-device-info": "*",
109
+ "react-native-dynamic-fonts": "*",
110
+ "react-native-gesture-handler": "*",
111
+ "react-native-get-random-values": "*",
112
+ "react-native-in-app-review": "*",
113
+ "react-native-linear-gradient": "*",
114
+ "react-native-mask-input": "*",
115
+ "react-native-pager-view": "*",
116
+ "react-native-permissions": "*",
117
+ "react-native-safe-area-context": "*",
118
+ "react-native-svg": "*",
119
+ "react-native-vector-icons": "*"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "expo-font": {
123
+ "optional": true
124
+ },
125
+ "react-native-dynamic-fonts": {
126
+ "optional": true
127
+ }
116
128
  },
117
129
  "workspaces": [
118
130
  "example"
@@ -15,7 +15,6 @@ import {
15
15
  requestInAppReview,
16
16
  isInAppReviewAvailable,
17
17
  } from '../native/inAppReview';
18
- import PagerView, { type PagerViewHandle } from '../native/pagerView';
19
18
  import { SafeAreaProvider } from '../native/safeAreaContext';
20
19
  import FlowboardRenderer from './FlowboardRenderer';
21
20
  import {
@@ -35,7 +34,6 @@ import { parseColor } from '../utils/flowboardUtils';
35
34
  const styles = StyleSheet.create({
36
35
  container: { flex: 1 },
37
36
  fullFlex: { flex: 1 },
38
- pagerPage: { width: '100%', height: '100%' },
39
37
  });
40
38
 
41
39
  export type FlowboardFlowProps = {
@@ -66,20 +64,15 @@ export default function FlowboardFlow(props: FlowboardFlowProps) {
66
64
  const repository = useMemo(() => new OnboardingRepository(), []);
67
65
  const assetPreloader = useMemo(() => new AssetPreloader(), []);
68
66
  const sliderRegistry = useMemo(() => new SliderRegistry(), []);
69
- const pagerRef = useRef<PagerViewHandle | null>(null);
70
67
  const [currentIndex, setCurrentIndex] = useState(() =>
71
68
  resolveInitialPage(initialStep, screens.length)
72
69
  );
73
- const [activePages, setActivePages] = useState<Record<number, true>>(() => ({
74
- [resolveInitialPage(initialStep, screens.length)]: true,
75
- }));
76
70
  const [formData, setFormData] = useState<Record<string, any>>({
77
71
  ...initialFormData,
78
72
  });
79
73
  const formDataRef = useRef<Record<string, any>>({
80
74
  ...initialFormData,
81
75
  });
82
- const didSyncPagerRef = useRef(false);
83
76
  const completedRef = useRef(false);
84
77
  const flowStartTimeRef = useRef(Date.now());
85
78
  const currentScreenData =
@@ -104,23 +97,6 @@ export default function FlowboardFlow(props: FlowboardFlowProps) {
104
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
105
98
  }, []);
106
99
 
107
- useEffect(() => {
108
- if (!pagerRef.current) return;
109
-
110
- const frameId = requestAnimationFrame(() => {
111
- if (!pagerRef.current) return;
112
-
113
- if (!didSyncPagerRef.current) {
114
- pagerRef.current.setPageWithoutAnimation(currentIndex);
115
- didSyncPagerRef.current = true;
116
- } else {
117
- pagerRef.current.setPage(currentIndex);
118
- }
119
- });
120
-
121
- return () => cancelAnimationFrame(frameId);
122
- }, [currentIndex]);
123
-
124
100
  const notifyStepChange = (index: number, preloadNext = true) => {
125
101
  if (index < 0 || index >= screens.length) return;
126
102
  const screenData = screens[index] as Record<string, any>;
@@ -142,16 +118,8 @@ export default function FlowboardFlow(props: FlowboardFlowProps) {
142
118
  }
143
119
  };
144
120
 
145
- const markPageAsActive = (index: number) => {
146
- setActivePages((prev) => {
147
- if (prev[index]) return prev;
148
- return { ...prev, [index]: true };
149
- });
150
- };
151
-
152
121
  const moveToIndex = (nextIndex: number) => {
153
122
  if (nextIndex < 0 || nextIndex >= screens.length) return;
154
- markPageAsActive(nextIndex);
155
123
  setCurrentIndex(nextIndex);
156
124
  notifyStepChange(nextIndex);
157
125
  };
@@ -418,6 +386,36 @@ export default function FlowboardFlow(props: FlowboardFlowProps) {
418
386
  persistProgress(index, next);
419
387
  };
420
388
 
389
+ const renderCurrentScreen = () => {
390
+ const screen = screens[currentIndex];
391
+ if (!screen || typeof screen !== 'object') return null;
392
+
393
+ const screenData = screen as Record<string, any>;
394
+ const screenType = screenData.type;
395
+
396
+ if (screenType === 'custom' && customScreenBuilder) {
397
+ const ctx = createContext(currentIndex);
398
+ return customScreenBuilder(ctx);
399
+ }
400
+
401
+ return (
402
+ <SliderRegistryProvider registry={sliderRegistry}>
403
+ <FlowboardRenderer
404
+ screenData={screenData}
405
+ formData={formData}
406
+ onInputChange={(id, value) =>
407
+ handleInputChange(id, value, currentIndex)
408
+ }
409
+ onAction={(action, payload) =>
410
+ handleAction(action, currentIndex, screens.length, payload)
411
+ }
412
+ currentIndex={currentIndex}
413
+ totalScreens={screens.length}
414
+ />
415
+ </SliderRegistryProvider>
416
+ );
417
+ };
418
+
421
419
  return (
422
420
  <SafeAreaProvider>
423
421
  <View
@@ -428,56 +426,9 @@ export default function FlowboardFlow(props: FlowboardFlowProps) {
428
426
  : undefined,
429
427
  ]}
430
428
  >
431
- <PagerView
432
- ref={pagerRef}
433
- style={styles.fullFlex}
434
- scrollEnabled={false}
435
- initialPage={currentIndex}
436
- >
437
- {screens.map((screen, index) => {
438
- const screenData = screen as Record<string, any>;
439
- const screenType = screenData.type;
440
- const isActivePage = activePages[index] === true;
441
-
442
- if (screenType === 'custom' && customScreenBuilder) {
443
- const ctx = createContext(index);
444
- return (
445
- <View
446
- key={`screen-${index}`}
447
- collapsable={false}
448
- style={styles.pagerPage}
449
- >
450
- {isActivePage ? customScreenBuilder(ctx) : null}
451
- </View>
452
- );
453
- }
454
-
455
- return (
456
- <View
457
- key={`screen-${index}`}
458
- collapsable={false}
459
- style={styles.pagerPage}
460
- >
461
- {isActivePage ? (
462
- <SliderRegistryProvider registry={sliderRegistry}>
463
- <FlowboardRenderer
464
- screenData={screenData}
465
- formData={formData}
466
- onInputChange={(id, value) =>
467
- handleInputChange(id, value, index)
468
- }
469
- onAction={(action, payload) =>
470
- handleAction(action, index, screens.length, payload)
471
- }
472
- currentIndex={currentIndex}
473
- totalScreens={screens.length}
474
- />
475
- </SliderRegistryProvider>
476
- ) : null}
477
- </View>
478
- );
479
- })}
480
- </PagerView>
429
+ <View key={`screen-${currentIndex}`} style={styles.fullFlex}>
430
+ {renderCurrentScreen()}
431
+ </View>
481
432
  </View>
482
433
  </SafeAreaProvider>
483
434
  );