@quiltt/react 1.2.7 → 1.2.8

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 (2) hide show
  1. package/README.md +137 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # @quiltt/react
2
+
3
+ ## Overview
4
+
5
+ `@quiltt/react` is a comprehensive JavaScript library that provides essential functionality for building applications using React. It extends the capabilities of React by offering various modules, utilities, and types from `@quiltt/core` that can be utilized to enhance your development workflow.
6
+
7
+ ## Installation
8
+
9
+ To install `@quiltt/react` in your project, you need to have Node.js and npm (Node Package Manager) installed. Then, you can run the following command:
10
+
11
+ ```shell
12
+ npm install @quiltt/react
13
+ ```
14
+
15
+ ## Features
16
+
17
+ `@quiltt/react` provides the following features:
18
+
19
+ - Integration with `@quiltt/core` library, which includes modules for JSON Web Tokens (JWT), observables, storage management, timeouts, API handling, and TypeScript types.
20
+ - Additional React-specific hooks and utilities for session management, storage, and Quiltt client integration.
21
+
22
+ ## Available Exports
23
+
24
+ ### Core Modules and Types
25
+
26
+ The following exports are available from `@quiltt/core`:
27
+
28
+ - JSON Web Token functionality, observable patterns, storage management, timeouts, API handling, and TypeScript types.
29
+
30
+ ### React Hooks
31
+
32
+ The following hooks are available from `@quiltt/react/hooks`:
33
+
34
+ - Helpers for handling Quiltt sessions and client integration.
35
+ - `useQuilttConnector`: A hook for connecting to the Quiltt backend.
36
+ - `useQuilttSession`: A hook for managing Quiltt sessions.
37
+ - `useQuilttSettings`: A hook for accessing Quiltt settings.
38
+
39
+ #### Usage
40
+
41
+ ##### useQuilttConnector
42
+
43
+ ```tsx
44
+ import { type FC } from 'react'
45
+ import { useQuilttConnector } from '@quiltt/react'
46
+
47
+ type ConnectorLauncherProps = {
48
+ connectorId: string
49
+ }
50
+
51
+ const ConnectorLauncher: FC<ConnectorLauncherProps> = ({ connectorId }) => {
52
+ const launcherClass = 'connector-launcher'
53
+
54
+ const { ready } = useQuilttConnector({
55
+ connectorId,
56
+ button: `.${launcherClass}`,
57
+ })
58
+
59
+ return (
60
+ <button type="button" disabled={!ready} className={launcherClass}>
61
+ Launch Connector
62
+ </button>
63
+ )
64
+ }
65
+ ```
66
+
67
+ ##### useQuilttSession
68
+
69
+ ```tsx
70
+ import { useEffect } from 'react'
71
+ import { useQuilttSession } from '@quiltt/react'
72
+
73
+ const MyComponent = () => {
74
+ const { session, importSession, authenticateSession, revokeSession } = useQuilttSession()
75
+
76
+ useEffect(() => {
77
+ // Import session from local storage or any other source
78
+ importSession()
79
+
80
+ // Authenticate session with your backend if necessary
81
+ authenticateSession()
82
+
83
+ // Clean up session when component unmounts
84
+ return () => {
85
+ revokeSession()
86
+ }
87
+ }, [importSession, authenticateSession, revokeSession])
88
+
89
+ return <div>{session ? <p>Session token: {session.token}</p> : <p>No session available</p>}</div>
90
+ }
91
+
92
+ export default MyComponent
93
+ ```
94
+
95
+ ##### useQuilttSettings
96
+
97
+ ```tsx
98
+ import { QuilttSettings, useQuilttSettings } from '@quiltt/react'
99
+
100
+ const App = () => {
101
+ // Wrap your application with QuilttSettingsProvider to provide the settings
102
+ return (
103
+ <QuilttSettings.Provider value={{ clientId: 'YOUR_CLIENT_ID' }}>
104
+ <MyComponent />
105
+ </QuilttSettings.Provider>
106
+ )
107
+ }
108
+
109
+ const MyComponent = () => {
110
+ const { clientId } = useQuilttSettings()
111
+
112
+ return (
113
+ <div>
114
+ <p>Quiltt Client ID: {clientId}</p>
115
+ {/* Rest of your component */}
116
+ </div>
117
+ )
118
+ }
119
+
120
+ export default App
121
+ ```
122
+
123
+ ### React Providers
124
+
125
+ The following providers are available from `@quiltt/react/providers`:
126
+
127
+ - `QuilttAuthProvider`: A provider component for authenticating with Quiltt.
128
+ - `QuilttProvider`: A provider component for initializing Quiltt.
129
+ - `QuilttSettingsProvider`: A provider component for managing Quiltt settings.
130
+
131
+ ## License
132
+
133
+ This project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE.md) file for more information.
134
+
135
+ For information on how to contribute to this project, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
136
+
137
+ By contributing to `@quiltt/react`, you can help improve its features and functionality. We appreciate your contributions and thank you for your support!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/react",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/quiltt/quiltt-public.git",
@@ -33,7 +33,7 @@
33
33
  "dist/**"
34
34
  ],
35
35
  "dependencies": {
36
- "@quiltt/core": "1.2.7"
36
+ "@quiltt/core": "1.2.8"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@apollo/client": "3.7.16",