@scalar/api-client-react 0.5.14 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,289 @@
1
1
  # @scalar/api-client-react
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2945efe: chore: make api client react public
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - e41c15e: fix: SSR issue with api-client-react
14
+
15
+ ## 0.5.45
16
+
17
+ ### Patch Changes
18
+
19
+ - 33f5a09: fix: revived the api-client-react package
20
+ - Updated dependencies [23d498b]
21
+ - Updated dependencies [624696e]
22
+ - Updated dependencies [41341e9]
23
+ - Updated dependencies [5402338]
24
+ - Updated dependencies [33f5a09]
25
+ - Updated dependencies [9f4db12]
26
+ - Updated dependencies [aee3783]
27
+ - Updated dependencies [9ca5d7d]
28
+ - Updated dependencies [d97bffd]
29
+ - @scalar/api-client@2.0.28
30
+
31
+ ## 0.5.44
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [19d8b6a]
36
+ - Updated dependencies [c112f24]
37
+ - Updated dependencies [83fc241]
38
+ - Updated dependencies [2e1ef12]
39
+ - @scalar/api-client@2.0.27
40
+
41
+ ## 0.5.43
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [54f7654]
46
+ - Updated dependencies [b0b3290]
47
+ - Updated dependencies [7e01b12]
48
+ - Updated dependencies [b7211fb]
49
+ - @scalar/api-client@2.0.26
50
+
51
+ ## 0.5.42
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [591fe24]
56
+ - Updated dependencies [7f17fe4]
57
+ - Updated dependencies [1dab515]
58
+ - Updated dependencies [4d76ff5]
59
+ - Updated dependencies [e8cd161]
60
+ - Updated dependencies [a431eb0]
61
+ - Updated dependencies [ff59399]
62
+ - Updated dependencies [ec47287]
63
+ - Updated dependencies [747e80e]
64
+ - Updated dependencies [9d561b7]
65
+ - @scalar/api-client@2.0.25
66
+
67
+ ## 0.5.41
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [7076725]
72
+ - Updated dependencies [1e72b03]
73
+ - Updated dependencies [cbe984b]
74
+ - @scalar/api-client@2.0.24
75
+
76
+ ## 0.5.40
77
+
78
+ ### Patch Changes
79
+
80
+ - Updated dependencies [3928ac3]
81
+ - @scalar/api-client@2.0.23
82
+
83
+ ## 0.5.39
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies [45b956f]
88
+ - @scalar/api-client@2.0.22
89
+
90
+ ## 0.5.38
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [d48e4ac]
95
+ - @scalar/api-client@2.0.21
96
+
97
+ ## 0.5.37
98
+
99
+ ### Patch Changes
100
+
101
+ - @scalar/api-client@2.0.20
102
+
103
+ ## 0.5.36
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [a0bb23a]
108
+ - @scalar/api-client@2.0.19
109
+
110
+ ## 0.5.35
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [8654323]
115
+ - @scalar/api-client@2.0.18
116
+
117
+ ## 0.5.34
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [91b97fa]
122
+ - Updated dependencies [05bc858]
123
+ - Updated dependencies [05bc858]
124
+ - @scalar/api-client@2.0.17
125
+
126
+ ## 0.5.33
127
+
128
+ ### Patch Changes
129
+
130
+ - fc096b6: refactor!: rename `createScalarApiClient` to `createApiClientModal`
131
+ - Updated dependencies [a5b295c]
132
+ - Updated dependencies [bff602a]
133
+ - Updated dependencies [6f4d20d]
134
+ - Updated dependencies [1ba4267]
135
+ - Updated dependencies [58da2c6]
136
+ - Updated dependencies [9e3348a]
137
+ - Updated dependencies [fe16789]
138
+ - Updated dependencies [fc096b6]
139
+ - Updated dependencies [ebdc9cf]
140
+ - @scalar/api-client@2.0.16
141
+
142
+ ## 0.5.32
143
+
144
+ ### Patch Changes
145
+
146
+ - Updated dependencies [f86a242]
147
+ - @scalar/api-client@2.0.15
148
+
149
+ ## 0.5.31
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [6b32eee]
154
+ - Updated dependencies [1a675be]
155
+ - Updated dependencies [a1d59de]
156
+ - @scalar/api-client@2.0.14
157
+
158
+ ## 0.5.30
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [618285e]
163
+ - @scalar/api-client@2.0.13
164
+
165
+ ## 0.5.29
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies [0a33194]
170
+ - @scalar/api-client@2.0.12
171
+
172
+ ## 0.5.28
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies [e8a7f82]
177
+ - Updated dependencies [c16413d]
178
+ - Updated dependencies [b9a7a4e]
179
+ - @scalar/api-client@2.0.11
180
+
181
+ ## 0.5.27
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [b65d1fa]
186
+ - Updated dependencies [b655c7a]
187
+ - @scalar/api-client@2.0.10
188
+
189
+ ## 0.5.26
190
+
191
+ ### Patch Changes
192
+
193
+ - Updated dependencies [1bb94c7]
194
+ - Updated dependencies [f1b5390]
195
+ - Updated dependencies [ad7fd7e]
196
+ - @scalar/api-client@2.0.9
197
+
198
+ ## 0.5.25
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies [ba3f5cb]
203
+ - Updated dependencies [0b6e3aa]
204
+ - Updated dependencies [d58841b]
205
+ - @scalar/api-client@2.0.8
206
+
207
+ ## 0.5.24
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [f2e3b0e]
212
+ - @scalar/api-client@2.0.7
213
+
214
+ ## 0.5.23
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies [4385ae2]
219
+ - Updated dependencies [632d6f7]
220
+ - Updated dependencies [a5aedf5]
221
+ - Updated dependencies [a5aedf5]
222
+ - Updated dependencies [d6a2a4d]
223
+ - Updated dependencies [cd5d1a4]
224
+ - @scalar/api-client@2.0.6
225
+
226
+ ## 0.5.22
227
+
228
+ ### Patch Changes
229
+
230
+ - Updated dependencies [6709507]
231
+ - Updated dependencies [8f06fcd]
232
+ - Updated dependencies [8f06fcd]
233
+ - Updated dependencies [cdfb8c5]
234
+ - @scalar/api-client@2.0.5
235
+
236
+ ## 0.5.21
237
+
238
+ ### Patch Changes
239
+
240
+ - @scalar/api-client@2.0.4
241
+
242
+ ## 0.5.20
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies [9f208d5]
247
+ - @scalar/api-client@2.0.3
248
+
249
+ ## 0.5.19
250
+
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies [209a7e1]
254
+ - Updated dependencies [429e928]
255
+ - Updated dependencies [3ba80b9]
256
+ - @scalar/api-client@2.0.2
257
+
258
+ ## 0.5.18
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies [ec52346]
263
+ - Updated dependencies [ded1303]
264
+ - Updated dependencies [6aae9fe]
265
+ - @scalar/api-client@2.0.1
266
+
267
+ ## 0.5.17
268
+
269
+ ### Patch Changes
270
+
271
+ - Updated dependencies [bd67d8f]
272
+ - @scalar/api-client@2.0.0
273
+
274
+ ## 0.5.16
275
+
276
+ ### Patch Changes
277
+
278
+ - @scalar/api-client@1.3.21
279
+
280
+ ## 0.5.15
281
+
282
+ ### Patch Changes
283
+
284
+ - Updated dependencies [cefe804]
285
+ - @scalar/api-client@1.3.20
286
+
3
287
  ## 0.5.14
4
288
 
5
289
  ### Patch Changes
package/README.md CHANGED
@@ -13,79 +13,35 @@ npm install @scalar/api-client-react
13
13
 
14
14
  ## Usage
15
15
 
16
- ```ts
17
- import { ApiClientReact } from '@scalar/api-client-react'
18
- import React, { useState } from 'react'
19
-
20
- export const Wrapper = () => {
21
- const [isOpen, setIsOpen] = useState(false)
22
-
23
- return (
24
- <>
25
- <button onClick={() => setIsOpen(true)}>
26
- Click me to open the Api Client
27
- </button>
28
-
29
- <ApiClientReact
30
- close={() => setIsOpen(false)}
31
- isOpen={isOpen}
32
- request={{
33
- url: 'https://api.sampleapis.com',
34
- type: 'GET',
35
- path: '/simpsons/products',
36
- }}
37
- />
38
- </>
39
- )
40
- }
41
- ```
42
-
43
- You will also need one of the following classes on a parent element:
44
-
45
- ```css
46
- .dark-mode
47
- .light-mode
16
+ First we need to add the provider, you should add it in the highest place you have a unique spec.
17
+
18
+ ```tsx
19
+ import { ApiClientModalProvider } from '@scalar/api-client-react'
20
+ import '@scalar/api-client-react/style.css'
21
+
22
+ ;<ApiClientModalProvider
23
+ configuration={{
24
+ spec: {
25
+ url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
26
+ },
27
+ }}>
28
+ {children}
29
+ </ApiClientModalProvider>
48
30
  ```
49
31
 
50
- ## Props
32
+ Then you can trigger it from anywhere inside of that provider by calling the `useApiClientModal()`
51
33
 
52
- ### close: function
34
+ ```tsx
35
+ import { useApiClientModal } from '@scalar/api-client-react'
53
36
 
54
- function to close the dialog, as seen above
37
+ const client = useApiClientModal()
55
38
 
56
- ### isOpen: boolean
57
-
58
- boolean which controls the visibility of the dialog containing the client
59
-
60
- ### request: ClientRequestConfig
61
-
62
- ```ts
63
- export type ClientRequestConfig = {
64
- id?: string
65
- name?: string
66
- url: string
67
- /** HTTP Request Method */
68
- type: string
69
- /** Request path */
70
- path: string
71
- /** Variables */
72
- variables?: BaseParameter[]
73
- /** Query parameters */
74
- query?: Query[]
75
- /** Cookies */
76
- cookies?: Cookie[]
77
- /** Request headers */
78
- headers?: Header[]
79
- /** Content type matched body */
80
- body?: string
81
- /** Optional form data body */
82
- formData?: FormDataItem[]
83
- }
39
+ return (
40
+ <button
41
+ onClick={() => client?.open({ path: '/auth/token', method: 'get' })}>
42
+ Click me to open the Api Client
43
+ </button>
44
+ )
84
45
  ```
85
46
 
86
- ## ApiClientReactBase
87
-
88
- We also export the base component if you do not want the modal.
89
- `ApiClientReactBase`
90
-
91
- Details on how to use it can be found in the source code for `ApiClientReact`
47
+ Check out the playground for a working example.