@youversion/platform-react-ui 0.6.0 → 0.8.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.
- package/README.md +6 -6
- package/dist/components/{SignInButton.d.ts → YouVersionAuthButton.d.ts} +28 -29
- package/dist/components/YouVersionAuthButton.d.ts.map +1 -0
- package/dist/components/{SignInButton.stories.d.ts → YouVersionAuthButton.stories.d.ts} +10 -13
- package/dist/components/YouVersionAuthButton.stories.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/verse-of-the-day.stories.d.ts.map +1 -1
- package/dist/index.cjs +629 -654
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +620 -642
- package/dist/tailwind.css +1 -1
- package/package.json +5 -5
- package/dist/components/SignInButton.d.ts.map +0 -1
- package/dist/components/SignInButton.stories.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/useAuthentication.d.ts +0 -8
- package/dist/hooks/useAuthentication.d.ts.map +0 -1
- package/dist/providers/YVPErrorBoundary.d.ts +0 -17
- package/dist/providers/YVPErrorBoundary.d.ts.map +0 -1
- package/dist/providers/YVPErrorBoundary.test.d.ts +0 -2
- package/dist/providers/YVPErrorBoundary.test.d.ts.map +0 -1
- package/dist/providers/YVPProvider.d.ts +0 -20
- package/dist/providers/YVPProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -3
- package/dist/providers/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -30,13 +30,13 @@ Get your App Key at [platform.youversion.com](https://platform.youversion.com/)
|
|
|
30
30
|
Wrap your app with the provider and use components:
|
|
31
31
|
|
|
32
32
|
```tsx
|
|
33
|
-
import {
|
|
33
|
+
import { YouVersionProvider, BibleTextView } from '@youversion/platform-react-ui';
|
|
34
34
|
|
|
35
35
|
function App() {
|
|
36
36
|
return (
|
|
37
|
-
<
|
|
37
|
+
<YouVersionProvider appKey={"YOUR_APP_KEY"}>
|
|
38
38
|
<BibleTextView reference="JHN.1.1-4" versionId={111} />
|
|
39
|
-
</
|
|
39
|
+
</YouVersionProvider>
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
```
|
|
@@ -47,20 +47,20 @@ Toggle theme via the `YVPProvider`:
|
|
|
47
47
|
|
|
48
48
|
```tsx
|
|
49
49
|
import { useState } from 'react';
|
|
50
|
-
import {
|
|
50
|
+
import { YouVersionProvider, YVPProvider, BibleTextView } from '@youversion/platform-react-ui';
|
|
51
51
|
|
|
52
52
|
export default function App() {
|
|
53
53
|
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
|
-
<
|
|
56
|
+
<YouVersionProvider appKey="YOUR_APP_KEY">
|
|
57
57
|
<YVPProvider config={{ appKey: "YOUR_APP_KEY" }} theme={theme}>
|
|
58
58
|
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
59
59
|
Toggle theme
|
|
60
60
|
</button>
|
|
61
61
|
<BibleTextView reference="JHN.1.1-4" versionId={111} />
|
|
62
62
|
</YVPProvider>
|
|
63
|
-
</
|
|
63
|
+
</YouVersionProvider>
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
```
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type SignInWithYouVersionPermissionValues
|
|
2
|
+
import { type SignInWithYouVersionPermissionValues } from '@youversion/platform-core';
|
|
3
3
|
interface SignInAuthProps {
|
|
4
4
|
/**
|
|
5
5
|
* Called when the sign-in flow fails.
|
|
6
6
|
* @param error - The error thrown by the sign-in flow.
|
|
7
7
|
*/
|
|
8
8
|
onAuthError?: (error: Error) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Called when the sign-in flow succeeds.
|
|
11
|
-
* @param result - The result of the sign-in flow.
|
|
12
|
-
*/
|
|
13
|
-
onSuccess?: (result: SignInWithYouVersionResult) => void;
|
|
14
9
|
/**
|
|
15
10
|
* Permissions that are requested but not required for sign-in to succeed.
|
|
16
11
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* Permissions that must be granted for sign-in to succeed.
|
|
20
|
-
*/
|
|
21
|
-
requiredPermissions?: SignInWithYouVersionPermissionValues[];
|
|
12
|
+
permissions?: SignInWithYouVersionPermissionValues[];
|
|
13
|
+
redirectUrl: string;
|
|
22
14
|
}
|
|
23
|
-
export interface
|
|
15
|
+
export interface YouVersionAuthButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, SignInAuthProps {
|
|
24
16
|
/**
|
|
25
17
|
* The background color of the button.
|
|
26
18
|
*
|
|
@@ -49,32 +41,40 @@ export interface SignInButtonProps extends React.ButtonHTMLAttributes<HTMLButton
|
|
|
49
41
|
* - `outline` - Button with contrast border.
|
|
50
42
|
*/
|
|
51
43
|
variant?: 'default' | 'outline';
|
|
44
|
+
/**
|
|
45
|
+
* The mode of the signIn/SignOut button
|
|
46
|
+
*
|
|
47
|
+
* - `signIn` - Renders the YouVersionAuthButton
|
|
48
|
+
* - `signOut` - Renders the SignOutButton
|
|
49
|
+
* - `auto` - Renders the YouVersionAuthButton when there
|
|
50
|
+
* is not a user signed in and renders the SignOutButton
|
|
51
|
+
* when there is a user signed in.
|
|
52
|
+
*
|
|
53
|
+
* */
|
|
54
|
+
mode?: 'signIn' | 'signOut' | 'auto';
|
|
52
55
|
}
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
57
|
+
* YouVersionAuthButton - Initiates the YouVersion OAuth sign-in flow on click.
|
|
55
58
|
*
|
|
56
59
|
* Key behaviors:
|
|
57
60
|
* - Prevents default click behavior and triggers the SDK `signIn` method.
|
|
58
|
-
* - Calls `onSuccess` with the SignInWithYouVersionResult when sign-in succeeds.
|
|
59
61
|
* - Calls `onAuthError` when the underlying sign-in flow throws.
|
|
60
62
|
*
|
|
61
|
-
* @param {
|
|
63
|
+
* @param {YouVersionAuthButtonProps} props - Component props (see {@link YouVersionAuthButtonProps}).
|
|
62
64
|
* @returns {React.ReactElement} A button element that starts the sign-in flow.
|
|
63
65
|
*
|
|
64
66
|
* @example
|
|
65
|
-
* import {
|
|
66
|
-
* import {
|
|
67
|
+
* import { YouVersionAuthButton, SignInWithYouVersionPermission } from '@youversion/platform-react-ui';
|
|
68
|
+
* import { useYVAuth } from '@youversion/platform-react-hooks';
|
|
67
69
|
*
|
|
68
70
|
* export default function UnauthenticatedView() {
|
|
69
|
-
* const auth =
|
|
71
|
+
* const { auth } = useYVAuth();
|
|
70
72
|
*
|
|
71
73
|
* return (
|
|
72
74
|
* <div>
|
|
73
75
|
* {auth.error && <p className="text-red-600">Error: {auth.error.message}</p>}
|
|
74
|
-
* <
|
|
75
|
-
*
|
|
76
|
-
* optionalPermissions={[SignInWithYouVersionPermission.highlights]}
|
|
77
|
-
* onSuccess={(result) => console.log('signed in', result)}
|
|
76
|
+
* <YouVersionAuthButton
|
|
77
|
+
* permissions={[SignInWithYouVersionPermission.bibles]}
|
|
78
78
|
* onAuthError={(err) => console.error(err)}
|
|
79
79
|
* />
|
|
80
80
|
* </div>
|
|
@@ -83,19 +83,18 @@ export interface SignInButtonProps extends React.ButtonHTMLAttributes<HTMLButton
|
|
|
83
83
|
*
|
|
84
84
|
* @example
|
|
85
85
|
* // Example: different button styles shown in the example app
|
|
86
|
-
* <
|
|
87
|
-
* <
|
|
86
|
+
* <YouVersionAuthButton /> // default light background, labeled
|
|
87
|
+
* <YouVersionAuthButton size="short" variant="outline" /> // shorter label with outline
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
90
90
|
* // Example showing permission enum usage from the example app
|
|
91
91
|
* import { SignInWithYouVersionPermission } from '@youversion/platform-react-ui';
|
|
92
92
|
*
|
|
93
|
-
* <
|
|
94
|
-
*
|
|
95
|
-
* optionalPermissions={[SignInWithYouVersionPermission.highlights]}
|
|
93
|
+
* <YouVersionAuthButton
|
|
94
|
+
* permissions={[SignInWithYouVersionPermission.bibles]}
|
|
96
95
|
* />
|
|
97
96
|
*
|
|
98
97
|
*/
|
|
99
|
-
export declare const
|
|
98
|
+
export declare const YouVersionAuthButton: React.ForwardRefExoticComponent<YouVersionAuthButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
100
99
|
export {};
|
|
101
|
-
//# sourceMappingURL=
|
|
100
|
+
//# sourceMappingURL=YouVersionAuthButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YouVersionAuthButton.d.ts","sourceRoot":"","sources":["../../src/components/YouVersionAuthButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AAMtF,UAAU,eAAe;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,oCAAoC,EAAE,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,eAAe;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC;;;;;;;;;SASK;IACL,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,oBAAoB,qGAmIhC,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: import("react").ForwardRefExoticComponent<import("./
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<import("./YouVersionAuthButton").YouVersionAuthButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
parameters: {
|
|
6
6
|
layout: string;
|
|
7
7
|
};
|
|
8
8
|
tags: string[];
|
|
9
9
|
beforeEach(): Promise<void>;
|
|
10
10
|
args: {
|
|
11
|
-
|
|
11
|
+
redirectUrl: string;
|
|
12
12
|
onAuthError: import("storybook/test").Mock<(...args: any[]) => any>;
|
|
13
|
+
mode: "auto";
|
|
13
14
|
};
|
|
14
15
|
argTypes: {
|
|
15
16
|
onAuthError: {
|
|
@@ -17,22 +18,18 @@ declare const meta: {
|
|
|
17
18
|
disable: true;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
permissions: {
|
|
21
22
|
table: {
|
|
22
23
|
disable: true;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
requiredPermissions: {
|
|
31
|
-
table: {
|
|
32
|
-
disable: true;
|
|
26
|
+
background: {
|
|
27
|
+
control: {
|
|
28
|
+
type: "select";
|
|
33
29
|
};
|
|
30
|
+
options: string[];
|
|
34
31
|
};
|
|
35
|
-
|
|
32
|
+
mode: {
|
|
36
33
|
control: {
|
|
37
34
|
type: "select";
|
|
38
35
|
};
|
|
@@ -85,4 +82,4 @@ export declare const DarkRectangleShortOutline: Story;
|
|
|
85
82
|
export declare const DarkRectangleIcon: Story;
|
|
86
83
|
export declare const DarkRectangleIconOutline: Story;
|
|
87
84
|
export declare const InteractionTestWithMockedAuth: Story;
|
|
88
|
-
//# sourceMappingURL=
|
|
85
|
+
//# sourceMappingURL=Y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EAAE,KAK3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAMlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAMhC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,KAOvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAM/B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,KAOtC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,KAc3C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BibleChapterPicker, type RootProps, type TriggerProps } from './bible-chapter-picker';
|
|
2
2
|
export { BibleReader, type BibleReaderRootProps } from './bible-reader';
|
|
3
3
|
export { BibleVersionPicker, type BibleVersionPickerRootProps, type BibleVersionPickerTriggerProps, } from './bible-version-picker';
|
|
4
|
-
export {
|
|
4
|
+
export { YouVersionAuthButton, type YouVersionAuthButtonProps } from './YouVersionAuthButton';
|
|
5
5
|
export { VerseOfTheDay, type VerseOfTheDayProps } from './verse-of-the-day';
|
|
6
6
|
export { BibleTextView, type BibleTextViewProps } from './verse';
|
|
7
7
|
export { BibleWidgetView, type BibleWidgetViewProps } from './bible-widget-view';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EACL,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EACL,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verse-of-the-day.stories.d.ts","sourceRoot":"","sources":["../../src/components/verse-of-the-day.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAA,MAAM,IAAI;;;;;;;;;yBA2CE,KAAK,CAAC,aAAa,KAAG,KAAK,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCd,CAAC;AAEvC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"verse-of-the-day.stories.d.ts","sourceRoot":"","sources":["../../src/components/verse-of-the-day.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAA,MAAM,IAAI;;;;;;;;;yBA2CE,KAAK,CAAC,aAAa,KAAG,KAAK,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCd,CAAC;AAEvC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAmCrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAInB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAC"}
|