@scalar/api-reference-react 0.9.9 → 0.9.11
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 +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -0
- package/dist/style.css +12381 -1
- package/package.json +7 -13
- package/dist/ApiReferenceReact.js +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @scalar/api-reference-react
|
|
2
2
|
|
|
3
|
+
## 0.9.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#8466](https://github.com/scalar/scalar/pull/8466): chore: new build pipeline
|
|
8
|
+
|
|
9
|
+
## 0.9.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
#### Updated Dependencies
|
|
14
|
+
|
|
15
|
+
- **@scalar/api-reference@1.49.0**
|
|
16
|
+
- [#8443](https://github.com/scalar/scalar/pull/8443): fix hash-prefixed basePath routing
|
|
17
|
+
- [#8467](https://github.com/scalar/scalar/pull/8467): feat(api-reference): improve Ask AI button consistency and a11y
|
|
18
|
+
- [#8409](https://github.com/scalar/scalar/pull/8409): feat: lazy rendering
|
|
19
|
+
- [#8442](https://github.com/scalar/scalar/pull/8442): fix object schema descriptions in parameter rendering
|
|
20
|
+
|
|
3
21
|
## 0.9.9
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ReferenceProps } from '@scalar/api-reference';
|
|
2
2
|
/** Re-export types for ease of use */
|
|
3
3
|
export type { AnyApiReferenceConfiguration, ApiReferenceConfiguration, ApiReferenceConfigurationWithMultipleSources, } from '@scalar/types/api-reference';
|
|
4
|
-
export { ApiReferenceReact } from './ApiReferenceReact
|
|
4
|
+
export { ApiReferenceReact } from './ApiReferenceReact';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { createApiReference } from "@scalar/api-reference";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/ApiReferenceReact.tsx
|
|
6
|
+
globalThis.__VUE_OPTIONS_API__ = true;
|
|
7
|
+
globalThis.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = true;
|
|
8
|
+
globalThis.__VUE_PROD_DEVTOOLS__ = false;
|
|
9
|
+
/**
|
|
10
|
+
* React wrapper around the Scalar API Reference
|
|
11
|
+
*/
|
|
12
|
+
var ApiReferenceReact = (props) => {
|
|
13
|
+
const el = useRef(null);
|
|
14
|
+
const [reference, setReference] = useState(null);
|
|
15
|
+
/** handle adding the integration to the config */
|
|
16
|
+
const addIntegration = () => Array.isArray(props.configuration) ? props.configuration.map((c) => ({
|
|
17
|
+
_integration: "react",
|
|
18
|
+
...c
|
|
19
|
+
})) : {
|
|
20
|
+
_integration: "react",
|
|
21
|
+
...props.configuration
|
|
22
|
+
};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!el.current) return reference?.app?.unmount;
|
|
25
|
+
const instance = createApiReference(el.current, addIntegration());
|
|
26
|
+
setReference(instance);
|
|
27
|
+
return instance.destroy;
|
|
28
|
+
}, [el]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
reference?.updateConfiguration(addIntegration());
|
|
31
|
+
}, [props.configuration, reference]);
|
|
32
|
+
return /* @__PURE__ */ jsx("div", { ref: el });
|
|
4
33
|
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ApiReferenceReact };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/ApiReferenceReact.tsx"],"sourcesContent":["'use client'\n\nimport { createApiReference } from '@scalar/api-reference'\nimport type { AnyApiReferenceConfiguration, ApiReferenceInstance } from '@scalar/types/api-reference'\nimport { useEffect, useRef, useState } from 'react'\n\nimport './style.css'\n\n// These are required for the vue bundler version\nglobalThis.__VUE_OPTIONS_API__ = true\nglobalThis.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = true\nglobalThis.__VUE_PROD_DEVTOOLS__ = false\n\n/**\n * React wrapper around the Scalar API Reference\n */\nexport const ApiReferenceReact = (props: { configuration: AnyApiReferenceConfiguration }) => {\n const el = useRef<HTMLDivElement | null>(null)\n\n const [reference, setReference] = useState<ApiReferenceInstance | null>(null)\n\n /** handle adding the integration to the config */\n const addIntegration = () =>\n Array.isArray(props.configuration)\n ? props.configuration.map((c) => ({ _integration: 'react' as const, ...c }))\n : { _integration: 'react' as const, ...props.configuration }\n\n useEffect(() => {\n if (!el.current) {\n return reference?.app?.unmount\n }\n\n const instance = createApiReference(el.current, addIntegration())\n setReference(instance)\n\n // Unmount on cleanup\n return instance.destroy\n }, [el])\n\n useEffect(() => {\n reference?.updateConfiguration(addIntegration())\n }, [props.configuration, reference])\n\n return <div ref={el} />\n}\n"],"mappings":";;;;;AASA,WAAW,sBAAsB;AACjC,WAAW,0CAA0C;AACrD,WAAW,wBAAwB;;;;AAKnC,IAAa,qBAAqB,UAA2D;CAC3F,MAAM,KAAK,OAA8B,KAAK;CAE9C,MAAM,CAAC,WAAW,gBAAgB,SAAsC,KAAK;;CAG7E,MAAM,uBACJ,MAAM,QAAQ,MAAM,cAAc,GAC9B,MAAM,cAAc,KAAK,OAAO;EAAE,cAAc;EAAkB,GAAG;EAAG,EAAE,GAC1E;EAAE,cAAc;EAAkB,GAAG,MAAM;EAAe;AAEhE,iBAAgB;AACd,MAAI,CAAC,GAAG,QACN,QAAO,WAAW,KAAK;EAGzB,MAAM,WAAW,mBAAmB,GAAG,SAAS,gBAAgB,CAAC;AACjE,eAAa,SAAS;AAGtB,SAAO,SAAS;IACf,CAAC,GAAG,CAAC;AAER,iBAAgB;AACd,aAAW,oBAAoB,gBAAgB,CAAC;IAC/C,CAAC,MAAM,eAAe,UAAU,CAAC;AAEpC,QAAO,oBAAC,OAAD,EAAK,KAAK,IAAM,CAAA"}
|