@rocapine/react-native-onboarding 1.52.0 → 1.54.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.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/dist/OnboardingStudioClient.d.ts +8 -0
  3. package/dist/OnboardingStudioClient.d.ts.map +1 -1
  4. package/dist/OnboardingStudioClient.js +15 -0
  5. package/dist/OnboardingStudioClient.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +5 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/infra/queries/cacheKey.d.ts +20 -0
  11. package/dist/infra/queries/cacheKey.d.ts.map +1 -0
  12. package/dist/infra/queries/cacheKey.js +26 -0
  13. package/dist/infra/queries/cacheKey.js.map +1 -0
  14. package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -1
  15. package/dist/infra/queries/getOnboarding.query.js +20 -10
  16. package/dist/infra/queries/getOnboarding.query.js.map +1 -1
  17. package/dist/onboarding-example.d.ts +185 -0
  18. package/dist/onboarding-example.d.ts.map +1 -1
  19. package/dist/onboarding-example.js +27 -0
  20. package/dist/onboarding-example.js.map +1 -1
  21. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +120 -0
  22. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
  23. package/dist/steps/ComposableScreen/elements/DatePickerElement.js +15 -1
  24. package/dist/steps/ComposableScreen/elements/DatePickerElement.js.map +1 -1
  25. package/dist/types.d.ts +10 -0
  26. package/dist/types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/OnboardingStudioClient.ts +13 -0
  29. package/src/__tests__/getOnboarding.query.test.ts +76 -5
  30. package/src/index.ts +5 -0
  31. package/src/infra/queries/cacheKey.ts +24 -0
  32. package/src/infra/queries/getOnboarding.query.ts +20 -11
  33. package/src/onboarding-example.ts +27 -0
  34. package/src/steps/ComposableScreen/elements/DatePickerElement.ts +35 -0
  35. package/src/types.ts +10 -0
@@ -6,6 +6,39 @@ import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
6
6
  // would go stale (e.g. a max date that should always be today).
7
7
  const isDateStringOrNow = (s: string) => s === "now" || !isNaN(Date.parse(s));
8
8
 
9
+ // Subset of Intl.DateTimeFormatOptions used to format the displayed/stored
10
+ // label (Android trigger text + variable `label`). Forwarded as-is to the
11
+ // toLocale*String call matching the picker `mode`. NOTE: Intl throws if
12
+ // `dateStyle`/`timeStyle` is combined with component fields (hour/day/etc.) —
13
+ // authors must not mix the two; the schema does not enforce it.
14
+ export type DateTimeFormatOptions = {
15
+ weekday?: "long" | "short" | "narrow";
16
+ year?: "numeric" | "2-digit";
17
+ month?: "numeric" | "2-digit" | "long" | "short" | "narrow";
18
+ day?: "numeric" | "2-digit";
19
+ hour?: "numeric" | "2-digit";
20
+ minute?: "numeric" | "2-digit";
21
+ second?: "numeric" | "2-digit";
22
+ hour12?: boolean;
23
+ hourCycle?: "h11" | "h12" | "h23" | "h24";
24
+ dateStyle?: "full" | "long" | "medium" | "short";
25
+ timeStyle?: "full" | "long" | "medium" | "short";
26
+ };
27
+
28
+ export const DateTimeFormatOptionsSchema = z.object({
29
+ weekday: z.enum(["long", "short", "narrow"]).optional(),
30
+ year: z.enum(["numeric", "2-digit"]).optional(),
31
+ month: z.enum(["numeric", "2-digit", "long", "short", "narrow"]).optional(),
32
+ day: z.enum(["numeric", "2-digit"]).optional(),
33
+ hour: z.enum(["numeric", "2-digit"]).optional(),
34
+ minute: z.enum(["numeric", "2-digit"]).optional(),
35
+ second: z.enum(["numeric", "2-digit"]).optional(),
36
+ hour12: z.boolean().optional(),
37
+ hourCycle: z.enum(["h11", "h12", "h23", "h24"]).optional(),
38
+ dateStyle: z.enum(["full", "long", "medium", "short"]).optional(),
39
+ timeStyle: z.enum(["full", "long", "medium", "short"]).optional(),
40
+ });
41
+
9
42
  export type DatePickerElementProps = BaseBoxProps & {
10
43
  variableName?: string;
11
44
  defaultValue?: string;
@@ -16,6 +49,7 @@ export type DatePickerElementProps = BaseBoxProps & {
16
49
  textColor?: string;
17
50
  accentColor?: string;
18
51
  locale?: string;
52
+ format?: DateTimeFormatOptions;
19
53
  };
20
54
 
21
55
  export const DatePickerElementPropsSchema = BaseBoxPropsSchema.extend({
@@ -28,4 +62,5 @@ export const DatePickerElementPropsSchema = BaseBoxPropsSchema.extend({
28
62
  textColor: z.string().optional(),
29
63
  accentColor: z.string().optional(),
30
64
  locale: z.string().optional(),
65
+ format: DateTimeFormatOptionsSchema.optional(),
31
66
  });
package/src/types.ts CHANGED
@@ -24,6 +24,16 @@ export type OnboardingStudioClientOptions<
24
24
  baseUrl?: string;
25
25
  fallbackOnboarding?: Onboarding<StepType>;
26
26
  timeout?: number;
27
+ /**
28
+ * Optional custom cache key. When provided, the fetched onboarding is
29
+ * persisted under `"rocapine-onboarding-sdk-{cacheKey}"` and served
30
+ * **cache-first with no background revalidation** — the pinned version stays
31
+ * put across launches until the host refetches (see
32
+ * `OnboardingStudioClient.clearCache`). Omit for the default key
33
+ * (`"rocapine-onboarding-studio"`) with stale-while-revalidate caching.
34
+ * Ignored in sandbox mode (which always fetches fresh).
35
+ */
36
+ cacheKey?: string;
27
37
  };
28
38
 
29
39
  export type OnboardingOptions = {