@openpkg-ts/react 0.2.5 → 0.3.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 +152 -2
- package/dist/index.js +1 -1
- package/dist/shared/{chunk-j3c78zxw.js → chunk-kpvq09pv.js} +32 -6
- package/dist/styled.d.ts +610 -79
- package/dist/styled.js +1879 -251
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -28,6 +28,14 @@ import {
|
|
|
28
28
|
ParamRow,
|
|
29
29
|
Signature,
|
|
30
30
|
TypeTable,
|
|
31
|
+
// Section components
|
|
32
|
+
FunctionSection,
|
|
33
|
+
ClassSection,
|
|
34
|
+
InterfaceSection,
|
|
35
|
+
EnumSection,
|
|
36
|
+
VariableSection,
|
|
37
|
+
ExportCard,
|
|
38
|
+
ExportIndexPage,
|
|
31
39
|
} from '@openpkg-ts/react';
|
|
32
40
|
```
|
|
33
41
|
|
|
@@ -43,6 +51,13 @@ import {
|
|
|
43
51
|
| `ParamRow` | Single parameter row |
|
|
44
52
|
| `Signature` | Type signature renderer |
|
|
45
53
|
| `TypeTable` | Type properties table |
|
|
54
|
+
| `FunctionSection` | Function export section |
|
|
55
|
+
| `ClassSection` | Class export section |
|
|
56
|
+
| `InterfaceSection` | Interface export section |
|
|
57
|
+
| `EnumSection` | Enum export section |
|
|
58
|
+
| `VariableSection` | Variable/constant section |
|
|
59
|
+
| `ExportCard` | Single export card |
|
|
60
|
+
| `ExportIndexPage` | Index page for all exports |
|
|
46
61
|
|
|
47
62
|
### Styled Components
|
|
48
63
|
|
|
@@ -50,7 +65,27 @@ Pre-styled with Tailwind v4.
|
|
|
50
65
|
|
|
51
66
|
```tsx
|
|
52
67
|
import {
|
|
53
|
-
//
|
|
68
|
+
// Stripe/Supabase-style layout (NEW)
|
|
69
|
+
StripeAPIReferencePage,
|
|
70
|
+
APIReferenceLayout,
|
|
71
|
+
SyncScrollProvider,
|
|
72
|
+
MethodSection,
|
|
73
|
+
MethodSectionFromSpec,
|
|
74
|
+
|
|
75
|
+
// Parameter components (Stripe-style)
|
|
76
|
+
APIParameterItem,
|
|
77
|
+
NestedParameterToggle,
|
|
78
|
+
NestedParameterContainer,
|
|
79
|
+
ExpandableParameter,
|
|
80
|
+
EnumValuesSection,
|
|
81
|
+
|
|
82
|
+
// Code example components
|
|
83
|
+
ExampleChips,
|
|
84
|
+
CodePanel,
|
|
85
|
+
CollapsiblePanel,
|
|
86
|
+
ExampleSection,
|
|
87
|
+
|
|
88
|
+
// Full pages (original)
|
|
54
89
|
APIPage,
|
|
55
90
|
FunctionPage,
|
|
56
91
|
ClassPage,
|
|
@@ -78,7 +113,54 @@ import {
|
|
|
78
113
|
|
|
79
114
|
## Usage
|
|
80
115
|
|
|
81
|
-
###
|
|
116
|
+
### Stripe/Supabase-Style API Reference (NEW)
|
|
117
|
+
|
|
118
|
+
Two-column layout with synchronized scrolling:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { StripeAPIReferencePage } from '@openpkg-ts/react/styled';
|
|
122
|
+
import spec from './openpkg.json';
|
|
123
|
+
|
|
124
|
+
export default function APIReference() {
|
|
125
|
+
return <StripeAPIReferencePage spec={spec} />;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Features:
|
|
130
|
+
- Two-column layout (docs left, code examples right)
|
|
131
|
+
- Sticky right panel with synchronized scrolling
|
|
132
|
+
- Stripe-style nested parameters with expandable containers
|
|
133
|
+
- Rose Pine syntax highlighting
|
|
134
|
+
- Collapsible accordion panels
|
|
135
|
+
|
|
136
|
+
### Custom Stripe-Style Layout
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import {
|
|
140
|
+
APIReferenceLayout,
|
|
141
|
+
SyncScrollProvider,
|
|
142
|
+
MethodSectionFromSpec,
|
|
143
|
+
ExampleSection,
|
|
144
|
+
} from '@openpkg-ts/react/styled';
|
|
145
|
+
|
|
146
|
+
export default function CustomAPIPage({ spec }) {
|
|
147
|
+
return (
|
|
148
|
+
<SyncScrollProvider>
|
|
149
|
+
<APIReferenceLayout
|
|
150
|
+
examples={<ExamplesColumn spec={spec} />}
|
|
151
|
+
leftWidth="55%"
|
|
152
|
+
rightWidth="45%"
|
|
153
|
+
>
|
|
154
|
+
{spec.exports.map(exp => (
|
|
155
|
+
<MethodSectionFromSpec key={exp.name} spec={spec} export={exp} />
|
|
156
|
+
))}
|
|
157
|
+
</APIReferenceLayout>
|
|
158
|
+
</SyncScrollProvider>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Full API Page (Original)
|
|
82
164
|
|
|
83
165
|
```tsx
|
|
84
166
|
import { FullAPIReferencePage } from '@openpkg-ts/react/styled';
|
|
@@ -128,12 +210,36 @@ Convert spec data to component props:
|
|
|
128
210
|
|
|
129
211
|
```tsx
|
|
130
212
|
import {
|
|
213
|
+
// Original adapters
|
|
131
214
|
specParamToAPIParam,
|
|
132
215
|
specSchemaToAPISchema,
|
|
133
216
|
specExamplesToCodeExamples,
|
|
134
217
|
buildImportStatement,
|
|
135
218
|
getLanguagesFromExamples,
|
|
219
|
+
|
|
220
|
+
// New Stripe-style adapters
|
|
221
|
+
specParamToNestedParam,
|
|
222
|
+
specParamsToNestedParams,
|
|
223
|
+
resolveSchemaRef,
|
|
224
|
+
specExampleToCodeExample,
|
|
225
|
+
generateDefaultExample,
|
|
226
|
+
} from '@openpkg-ts/react/styled';
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Hooks
|
|
230
|
+
|
|
231
|
+
Extract method data from spec:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
import {
|
|
235
|
+
useMethodFromSpec,
|
|
236
|
+
useMethodsFromSpec,
|
|
237
|
+
extractMethodData,
|
|
136
238
|
} from '@openpkg-ts/react/styled';
|
|
239
|
+
|
|
240
|
+
// In component
|
|
241
|
+
const method = useMethodFromSpec(spec, 'createClient');
|
|
242
|
+
// Returns: { title, signature, description, parameters, examples, returnType, isAsync }
|
|
137
243
|
```
|
|
138
244
|
|
|
139
245
|
## Headless Utilities
|
|
@@ -148,6 +254,50 @@ import {
|
|
|
148
254
|
} from '@openpkg-ts/react';
|
|
149
255
|
```
|
|
150
256
|
|
|
257
|
+
## Component Registry
|
|
258
|
+
|
|
259
|
+
Install components via CLI (shadcn-compatible):
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# List available components
|
|
263
|
+
openpkg docs list
|
|
264
|
+
|
|
265
|
+
# Add Stripe-style components
|
|
266
|
+
openpkg docs add stripe-api-reference-page
|
|
267
|
+
openpkg docs add method-section-from-spec
|
|
268
|
+
openpkg docs add api-reference-layout sync-scroll-provider
|
|
269
|
+
openpkg docs add api-parameter-item expandable-property
|
|
270
|
+
openpkg docs add example-chips code-panel collapsible-panel
|
|
271
|
+
|
|
272
|
+
# Add original section components
|
|
273
|
+
openpkg docs add function-section class-section interface-section
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
29 components available:
|
|
277
|
+
- **Stripe-style Layouts**: `api-reference-layout`, `sync-scroll-provider`, `method-section`, `stripe-api-reference-page`, `method-section-from-spec`
|
|
278
|
+
- **Parameter Components**: `api-parameter-item`, `nested-parameter-toggle`, `nested-parameter-container`, `expandable-property`, `enum-values-section`
|
|
279
|
+
- **Code Examples**: `example-chips`, `code-panel`, `collapsible-panel`, `example-section`
|
|
280
|
+
- **Original Sections**: `function-section`, `class-section`, `interface-section`, `enum-section`, `variable-section`
|
|
281
|
+
- **Primitives**: `export-card`, `param-table`, `signature`, `members-table`, `type-table`
|
|
282
|
+
|
|
283
|
+
## React Layout Generation
|
|
284
|
+
|
|
285
|
+
Generate a single layout file that uses registry components:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
openpkg docs generate spec.json -f react -o ./app/api
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Creates:
|
|
292
|
+
- `layout.tsx` - Main layout with navigation
|
|
293
|
+
- `spec.json` - Bundled spec data
|
|
294
|
+
|
|
295
|
+
Then add components:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
openpkg docs add function-section class-section
|
|
299
|
+
```
|
|
300
|
+
|
|
151
301
|
## License
|
|
152
302
|
|
|
153
303
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
19
|
|
|
20
20
|
// src/components/headless/CollapsibleMethod.tsx
|
|
21
|
-
import { formatReturnType, formatSchema, getMemberBadges } from "@openpkg-ts/sdk";
|
|
21
|
+
import { formatReturnType, formatSchema, getMemberBadges } from "@openpkg-ts/sdk/browser";
|
|
22
22
|
import { useEffect, useState } from "react";
|
|
23
23
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
24
|
|
|
@@ -220,7 +220,7 @@ function ExampleBlock({
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
// src/components/headless/ExpandableProperty.tsx
|
|
223
|
-
import { formatSchema as formatSchema2 } from "@openpkg-ts/sdk";
|
|
223
|
+
import { formatSchema as formatSchema2 } from "@openpkg-ts/sdk/browser";
|
|
224
224
|
import { useState as useState3 } from "react";
|
|
225
225
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
226
226
|
|
|
@@ -365,7 +365,7 @@ function ExpandableProperty({
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// src/components/headless/MembersTable.tsx
|
|
368
|
-
import { formatSchema as formatSchema3, getMemberBadges as getMemberBadges2 } from "@openpkg-ts/sdk";
|
|
368
|
+
import { formatSchema as formatSchema3, getMemberBadges as getMemberBadges2 } from "@openpkg-ts/sdk/browser";
|
|
369
369
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
370
370
|
|
|
371
371
|
function groupMembersByKind(members) {
|
|
@@ -502,7 +502,7 @@ function MembersTable({
|
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
// src/components/headless/ParamTable.tsx
|
|
505
|
-
import { formatSchema as formatSchema4 } from "@openpkg-ts/sdk";
|
|
505
|
+
import { formatSchema as formatSchema4 } from "@openpkg-ts/sdk/browser";
|
|
506
506
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
507
507
|
|
|
508
508
|
function isParameter(item) {
|
|
@@ -576,7 +576,7 @@ function ParamTable({
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
// src/components/headless/Signature.tsx
|
|
579
|
-
import { buildSignatureString } from "@openpkg-ts/sdk";
|
|
579
|
+
import { buildSignatureString } from "@openpkg-ts/sdk/browser";
|
|
580
580
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
581
581
|
|
|
582
582
|
function Signature({
|
|
@@ -596,7 +596,7 @@ function Signature({
|
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
// src/components/headless/TypeTable.tsx
|
|
599
|
-
import { formatSchema as formatSchema5 } from "@openpkg-ts/sdk";
|
|
599
|
+
import { formatSchema as formatSchema5 } from "@openpkg-ts/sdk/browser";
|
|
600
600
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
601
601
|
|
|
602
602
|
function isParameter2(item) {
|
|
@@ -667,4 +667,30 @@ function TypeTable({
|
|
|
667
667
|
]
|
|
668
668
|
});
|
|
669
669
|
}
|
|
670
|
+
// src/components/headless/FunctionSection.tsx
|
|
671
|
+
import { formatSchema as formatSchema6 } from "@openpkg-ts/sdk/browser";
|
|
672
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
673
|
+
|
|
674
|
+
// src/components/headless/ClassSection.tsx
|
|
675
|
+
import { formatSchema as formatSchema7 } from "@openpkg-ts/sdk/browser";
|
|
676
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
677
|
+
|
|
678
|
+
// src/components/headless/InterfaceSection.tsx
|
|
679
|
+
import { formatSchema as formatSchema8 } from "@openpkg-ts/sdk/browser";
|
|
680
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
681
|
+
|
|
682
|
+
// src/components/headless/VariableSection.tsx
|
|
683
|
+
import { formatSchema as formatSchema9 } from "@openpkg-ts/sdk/browser";
|
|
684
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
685
|
+
|
|
686
|
+
// src/components/headless/EnumSection.tsx
|
|
687
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
688
|
+
|
|
689
|
+
// src/components/headless/ExportCard.tsx
|
|
690
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
691
|
+
|
|
692
|
+
// src/components/headless/ExportIndexPage.tsx
|
|
693
|
+
import { useMemo, useState as useState4 } from "react";
|
|
694
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
695
|
+
|
|
670
696
|
export { __toESM, __commonJS, CollapsibleMethod, getExampleCode, getExampleTitle, getExampleLanguage, cleanCode, ExampleBlock, NestedProperty, ExpandableProperty, groupMembersByKind, MemberRow, MembersTable, ParamRow, ParamTable, Signature, TypeTable };
|