@mdxui/payload 6.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/.turbo/turbo-typecheck.log +5 -0
- package/CHANGELOG.md +136 -0
- package/package.json +58 -0
- package/src/app-preview/AppPreview.tsx +304 -0
- package/src/app-preview/index.ts +16 -0
- package/src/auth/AdminAuthWrapper.tsx +20 -0
- package/src/auth/AuthProvider.tsx +241 -0
- package/src/auth/AutoLogin.tsx +70 -0
- package/src/auth/index.ts +4 -0
- package/src/authkit/ApiKeys.tsx +77 -0
- package/src/authkit/UserProfile.tsx +77 -0
- package/src/authkit/UserSecurity.tsx +77 -0
- package/src/authkit/WorkOSProvider.tsx +70 -0
- package/src/authkit/index.ts +34 -0
- package/src/authkit/theme.ts +102 -0
- package/src/authkit/useWidgetToken.ts +67 -0
- package/src/dev-tools/Browser.tsx +364 -0
- package/src/dev-tools/DevTools.tsx +106 -0
- package/src/dev-tools/Terminal.tsx +216 -0
- package/src/dev-tools/index.ts +4 -0
- package/src/index.ts +39 -0
- package/src/mdx-preview/MDXPreview.tsx +183 -0
- package/src/mdx-preview/MDXProvider.tsx +62 -0
- package/src/mdx-preview/PayloadMDXField.tsx +120 -0
- package/src/mdx-preview/index.ts +28 -0
- package/src/mdx-preview/useMDXCompiler.ts +95 -0
- package/src/site-preview/PayloadSiteField.tsx +167 -0
- package/src/site-preview/SitePreview.tsx +194 -0
- package/src/site-preview/index.ts +31 -0
- package/tsconfig.json +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @mdxui/payload
|
|
2
|
+
|
|
3
|
+
## 6.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a4337af]
|
|
8
|
+
- Updated dependencies [e485d70]
|
|
9
|
+
- Updated dependencies [9f95ff0]
|
|
10
|
+
- @mdxui/auth@1.1.0
|
|
11
|
+
- @mdxui/cockpit@6.0.1
|
|
12
|
+
- @mdxui/beacon@6.0.1
|
|
13
|
+
|
|
14
|
+
## 6.0.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @mdxui/beacon@6.0.0
|
|
19
|
+
- @mdxui/cockpit@6.0.0
|
|
20
|
+
- @mdxui/primitives@6.0.0
|
|
21
|
+
- mdxui@6.0.0
|
|
22
|
+
|
|
23
|
+
## 5.0.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- @mdxui/beacon@5.0.2
|
|
28
|
+
- @mdxui/cockpit@5.0.2
|
|
29
|
+
- @mdxui/primitives@5.0.2
|
|
30
|
+
- mdxui@5.0.2
|
|
31
|
+
|
|
32
|
+
## 5.0.1
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- @mdxui/beacon@5.0.1
|
|
37
|
+
- @mdxui/cockpit@5.0.1
|
|
38
|
+
- @mdxui/primitives@5.0.1
|
|
39
|
+
- mdxui@5.0.1
|
|
40
|
+
|
|
41
|
+
## 5.0.0
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- @mdxui/beacon@5.0.0
|
|
46
|
+
- @mdxui/cockpit@5.0.0
|
|
47
|
+
- @mdxui/primitives@5.0.0
|
|
48
|
+
- mdxui@5.0.0
|
|
49
|
+
|
|
50
|
+
## 4.0.0
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- @mdxui/beacon@4.0.0
|
|
55
|
+
- @mdxui/cockpit@4.0.0
|
|
56
|
+
- @mdxui/primitives@4.0.0
|
|
57
|
+
- mdxui@4.0.0
|
|
58
|
+
|
|
59
|
+
## 3.0.1
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- @mdxui/beacon@3.0.1
|
|
64
|
+
- @mdxui/cockpit@3.0.1
|
|
65
|
+
- @mdxui/primitives@3.0.1
|
|
66
|
+
- mdxui@3.0.1
|
|
67
|
+
|
|
68
|
+
## 3.0.0
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- @mdxui/beacon@3.0.0
|
|
73
|
+
- @mdxui/cockpit@3.0.0
|
|
74
|
+
- @mdxui/primitives@3.0.0
|
|
75
|
+
- mdxui@3.0.0
|
|
76
|
+
|
|
77
|
+
## 2.1.1
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies
|
|
82
|
+
- mdxui@2.1.1
|
|
83
|
+
- @mdxui/beacon@2.1.1
|
|
84
|
+
- @mdxui/cockpit@2.1.1
|
|
85
|
+
- @mdxui/primitives@2.1.1
|
|
86
|
+
|
|
87
|
+
## 2.0.0
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [8101194]
|
|
92
|
+
- mdxui@2.0.0
|
|
93
|
+
- @mdxui/beacon@2.0.0
|
|
94
|
+
|
|
95
|
+
## 1.0.0
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- Updated dependencies [defc863]
|
|
100
|
+
- Updated dependencies [adb0209]
|
|
101
|
+
- mdxui@1.0.0
|
|
102
|
+
- @mdxui/cockpit@1.0.0
|
|
103
|
+
- @mdxui/beacon@1.0.0
|
|
104
|
+
|
|
105
|
+
## 0.5.0
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [1e99336]
|
|
110
|
+
- @mdxui/beacon@0.5.0
|
|
111
|
+
|
|
112
|
+
## 0.4.1
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [4d0d1a0]
|
|
117
|
+
- mdxui@0.4.1
|
|
118
|
+
- @mdxui/primitives@0.4.1
|
|
119
|
+
- @mdxui/beacon@0.4.0
|
|
120
|
+
- @mdxui/cockpit@0.4.0
|
|
121
|
+
|
|
122
|
+
## 0.4.0
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- Updated dependencies [fccbde8]
|
|
127
|
+
- Updated dependencies [90785e5]
|
|
128
|
+
- @mdxui/beacon@0.4.0
|
|
129
|
+
- @mdxui/cockpit@0.4.0
|
|
130
|
+
|
|
131
|
+
## 0.3.0
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [2a6669a]
|
|
136
|
+
- @mdxui/beacon@0.3.0
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mdxui/payload",
|
|
3
|
+
"version": "6.0.1",
|
|
4
|
+
"description": "Payload CMS admin components and field UI for mdxui",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./auth": "./src/auth/index.ts",
|
|
11
|
+
"./authkit": "./src/authkit/index.ts",
|
|
12
|
+
"./dev-tools": "./src/dev-tools/index.ts",
|
|
13
|
+
"./mdx-preview": "./src/mdx-preview/index.ts",
|
|
14
|
+
"./site-preview": "./src/site-preview/index.ts",
|
|
15
|
+
"./app-preview": "./src/app-preview/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@mdx-js/mdx": "^3.1.0",
|
|
19
|
+
"@mdx-js/react": "^3.1.0",
|
|
20
|
+
"@radix-ui/themes": "^3.2.1",
|
|
21
|
+
"@tanstack/react-query": "^5.90.12",
|
|
22
|
+
"lucide-react": "^0.561.0",
|
|
23
|
+
"react": "^19.2.3",
|
|
24
|
+
"react-error-boundary": "^5.0.0",
|
|
25
|
+
"shiki": "^3.20.0",
|
|
26
|
+
"@mdxui/auth": "1.1.0",
|
|
27
|
+
"@mdxui/beacon": "6.0.1",
|
|
28
|
+
"@mdxui/cockpit": "6.0.1",
|
|
29
|
+
"@mdxui/primitives": "6.0.0",
|
|
30
|
+
"mdxui": "6.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "^19.2.7",
|
|
34
|
+
"@types/react-dom": "^19.2.3",
|
|
35
|
+
"typescript": "5.9.3",
|
|
36
|
+
"@mdxui/typescript-config": "6.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@payloadcms/ui": "^3.0.0",
|
|
40
|
+
"payload": "^3.0.0",
|
|
41
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@payloadcms/ui": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"payload": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"clean": "rm -rf .turbo node_modules"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { MDXLiveRenderer } from 'mdxui'
|
|
4
|
+
import type { AppComponents } from 'mdxui'
|
|
5
|
+
|
|
6
|
+
// Import App components from cockpit
|
|
7
|
+
import {
|
|
8
|
+
DeveloperDashboard,
|
|
9
|
+
KeysPage,
|
|
10
|
+
WebhooksEndpointsPage,
|
|
11
|
+
OverviewPage,
|
|
12
|
+
SettingsProfilePage,
|
|
13
|
+
TeamPage,
|
|
14
|
+
BillingPage,
|
|
15
|
+
RequestsPage,
|
|
16
|
+
} from '@mdxui/cockpit/developer'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* AppComponents implementation using the cockpit template
|
|
20
|
+
*
|
|
21
|
+
* This provides all the App components that can be used in MDX content
|
|
22
|
+
* for previewing SaaS application components in the Payload admin.
|
|
23
|
+
*/
|
|
24
|
+
const appComponents: Partial<AppComponents> = {
|
|
25
|
+
// Main dashboard
|
|
26
|
+
DeveloperDashboard: DeveloperDashboard as any,
|
|
27
|
+
|
|
28
|
+
// Page components that map to AppComponents interface
|
|
29
|
+
Dashboard: OverviewPage as any,
|
|
30
|
+
Settings: SettingsProfilePage as any,
|
|
31
|
+
|
|
32
|
+
// Optional feature components (auto-wire to collections)
|
|
33
|
+
APIKeys: KeysPage as any,
|
|
34
|
+
Webhooks: WebhooksEndpointsPage as any,
|
|
35
|
+
Team: TeamPage as any,
|
|
36
|
+
Billing: BillingPage as any,
|
|
37
|
+
Usage: RequestsPage as any,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AppPreviewProps {
|
|
41
|
+
/**
|
|
42
|
+
* MDX content to preview
|
|
43
|
+
*/
|
|
44
|
+
content: string
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional additional components to merge with AppComponents
|
|
48
|
+
*/
|
|
49
|
+
components?: Partial<AppComponents>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Optional className for the preview wrapper
|
|
53
|
+
*/
|
|
54
|
+
className?: string
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Debounce delay in milliseconds (default: 300ms)
|
|
58
|
+
*/
|
|
59
|
+
debounceMs?: number
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether to show status indicator (default: false)
|
|
63
|
+
*/
|
|
64
|
+
showStatus?: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* AppPreview - Live preview component for App templates in Payload admin
|
|
69
|
+
*
|
|
70
|
+
* This component uses MDXLiveRenderer with AppComponents from the cockpit
|
|
71
|
+
* template to provide real-time preview of SaaS application components
|
|
72
|
+
* (Dashboard, Settings, APIKeys, Webhooks, etc.) as users edit content
|
|
73
|
+
* in the Payload CMS.
|
|
74
|
+
*
|
|
75
|
+
* Features:
|
|
76
|
+
* - Real-time MDX compilation and rendering
|
|
77
|
+
* - Full AppComponents support (Dashboard, Settings, APIKeys, Webhooks, etc.)
|
|
78
|
+
* - Debounced updates to prevent excessive re-compilation
|
|
79
|
+
* - Graceful error handling with user-friendly error messages
|
|
80
|
+
* - Loading states with visual feedback
|
|
81
|
+
* - Integrates seamlessly with Payload's admin UI
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* // In a Payload field configuration:
|
|
86
|
+
* {
|
|
87
|
+
* name: 'content',
|
|
88
|
+
* type: 'textarea',
|
|
89
|
+
* admin: {
|
|
90
|
+
* components: {
|
|
91
|
+
* Field: (props) => (
|
|
92
|
+
* <div>
|
|
93
|
+
* <TextareaField {...props} />
|
|
94
|
+
* <AppPreview content={props.value} />
|
|
95
|
+
* </div>
|
|
96
|
+
* ),
|
|
97
|
+
* },
|
|
98
|
+
* },
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* // Standalone usage:
|
|
105
|
+
* <AppPreview
|
|
106
|
+
* content={mdxContent}
|
|
107
|
+
* className="border rounded-lg p-4"
|
|
108
|
+
* debounceMs={500}
|
|
109
|
+
* showStatus={true}
|
|
110
|
+
* />
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export function AppPreview({
|
|
114
|
+
content,
|
|
115
|
+
components: additionalComponents = {},
|
|
116
|
+
className = '',
|
|
117
|
+
debounceMs = 300,
|
|
118
|
+
showStatus = false,
|
|
119
|
+
}: AppPreviewProps) {
|
|
120
|
+
// Merge default app components with any additional components
|
|
121
|
+
const mergedComponents = {
|
|
122
|
+
...appComponents,
|
|
123
|
+
...additionalComponents,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className={className}>
|
|
128
|
+
{showStatus && (
|
|
129
|
+
<div
|
|
130
|
+
style={{
|
|
131
|
+
padding: '0.5rem 1rem',
|
|
132
|
+
fontSize: '0.875rem',
|
|
133
|
+
color: '#666',
|
|
134
|
+
backgroundColor: '#f9fafb',
|
|
135
|
+
borderBottom: '1px solid #e5e7eb',
|
|
136
|
+
fontWeight: 500,
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
App Preview
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
<MDXLiveRenderer
|
|
143
|
+
content={content}
|
|
144
|
+
components={mergedComponents}
|
|
145
|
+
debounceMs={debounceMs}
|
|
146
|
+
loadingComponent={<AppPreviewLoading />}
|
|
147
|
+
errorComponent={AppPreviewError}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Loading component for AppPreview
|
|
155
|
+
*/
|
|
156
|
+
function AppPreviewLoading() {
|
|
157
|
+
return (
|
|
158
|
+
<div
|
|
159
|
+
style={{
|
|
160
|
+
display: 'flex',
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
justifyContent: 'center',
|
|
163
|
+
padding: '3rem',
|
|
164
|
+
backgroundColor: '#f9fafb',
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<div
|
|
168
|
+
style={{
|
|
169
|
+
display: 'flex',
|
|
170
|
+
flexDirection: 'column',
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
gap: '1rem',
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
style={{
|
|
177
|
+
width: '2rem',
|
|
178
|
+
height: '2rem',
|
|
179
|
+
border: '3px solid #e5e7eb',
|
|
180
|
+
borderTopColor: '#3b82f6',
|
|
181
|
+
borderRadius: '50%',
|
|
182
|
+
animation: 'spin 1s linear infinite',
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
<style>{`
|
|
186
|
+
@keyframes spin {
|
|
187
|
+
to { transform: rotate(360deg); }
|
|
188
|
+
}
|
|
189
|
+
`}</style>
|
|
190
|
+
<p style={{ color: '#6b7280', fontSize: '0.875rem' }}>
|
|
191
|
+
Compiling App preview...
|
|
192
|
+
</p>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Error component for AppPreview
|
|
200
|
+
*/
|
|
201
|
+
function AppPreviewError({ error }: { error: Error }) {
|
|
202
|
+
return (
|
|
203
|
+
<div
|
|
204
|
+
style={{
|
|
205
|
+
padding: '1.5rem',
|
|
206
|
+
backgroundColor: '#fef2f2',
|
|
207
|
+
border: '1px solid #fecaca',
|
|
208
|
+
borderRadius: '0.5rem',
|
|
209
|
+
margin: '1rem',
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
<div
|
|
213
|
+
style={{
|
|
214
|
+
display: 'flex',
|
|
215
|
+
alignItems: 'flex-start',
|
|
216
|
+
gap: '0.75rem',
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
<div
|
|
220
|
+
style={{
|
|
221
|
+
flexShrink: 0,
|
|
222
|
+
width: '1.25rem',
|
|
223
|
+
height: '1.25rem',
|
|
224
|
+
color: '#dc2626',
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
<svg
|
|
228
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
229
|
+
viewBox="0 0 20 20"
|
|
230
|
+
fill="currentColor"
|
|
231
|
+
>
|
|
232
|
+
<path
|
|
233
|
+
fillRule="evenodd"
|
|
234
|
+
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z"
|
|
235
|
+
clipRule="evenodd"
|
|
236
|
+
/>
|
|
237
|
+
</svg>
|
|
238
|
+
</div>
|
|
239
|
+
<div style={{ flex: 1 }}>
|
|
240
|
+
<h3
|
|
241
|
+
style={{
|
|
242
|
+
margin: '0 0 0.5rem',
|
|
243
|
+
fontSize: '1rem',
|
|
244
|
+
fontWeight: 600,
|
|
245
|
+
color: '#991b1b',
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
MDX Compilation Error
|
|
249
|
+
</h3>
|
|
250
|
+
<pre
|
|
251
|
+
style={{
|
|
252
|
+
margin: 0,
|
|
253
|
+
fontSize: '0.875rem',
|
|
254
|
+
fontFamily: 'ui-monospace, monospace',
|
|
255
|
+
color: '#7f1d1d',
|
|
256
|
+
whiteSpace: 'pre-wrap',
|
|
257
|
+
wordBreak: 'break-word',
|
|
258
|
+
lineHeight: 1.5,
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
{error.message}
|
|
262
|
+
</pre>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Factory function to create a Payload field component with AppPreview
|
|
271
|
+
*
|
|
272
|
+
* This is a convenience function for adding AppPreview to Payload field
|
|
273
|
+
* configurations without having to manually wire up the field value.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```tsx
|
|
277
|
+
* import { createAppPreviewField } from '@mdxui/payload/app-preview'
|
|
278
|
+
*
|
|
279
|
+
* const AppPreviewField = createAppPreviewField({
|
|
280
|
+
* className: 'mt-4',
|
|
281
|
+
* showStatus: true,
|
|
282
|
+
* })
|
|
283
|
+
*
|
|
284
|
+
* // Use in collection config:
|
|
285
|
+
* {
|
|
286
|
+
* name: 'content',
|
|
287
|
+
* type: 'textarea',
|
|
288
|
+
* admin: {
|
|
289
|
+
* components: {
|
|
290
|
+
* afterInput: [AppPreviewField],
|
|
291
|
+
* },
|
|
292
|
+
* },
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export function createAppPreviewField(
|
|
297
|
+
defaultProps: Omit<AppPreviewProps, 'content'>
|
|
298
|
+
) {
|
|
299
|
+
return function AppPreviewField({ value }: { value: string }) {
|
|
300
|
+
if (!value) return null
|
|
301
|
+
|
|
302
|
+
return <AppPreview content={value} {...defaultProps} />
|
|
303
|
+
}
|
|
304
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppPreview - Live preview for App templates
|
|
3
|
+
*
|
|
4
|
+
* Real-time MDX rendering of App components (Dashboard, Settings, APIKeys, etc.)
|
|
5
|
+
* for Payload CMS admin panel.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { AppPreview } from '@mdxui/payload/app-preview'
|
|
10
|
+
*
|
|
11
|
+
* <AppPreview content={mdxContent} showStatus />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export { AppPreview, createAppPreviewField } from './AppPreview'
|
|
16
|
+
export type { AppPreviewProps } from './AppPreview'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
import { AuthProvider } from './AuthProvider'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper component for Payload admin that handles WorkOS auth refresh.
|
|
8
|
+
*
|
|
9
|
+
* This wraps the admin UI with AuthProvider which:
|
|
10
|
+
* 1. Monitors auth status every minute
|
|
11
|
+
* 2. Checks auth on window focus
|
|
12
|
+
* 3. Redirects to auto-login when token expires (oauth.do handles refresh)
|
|
13
|
+
*/
|
|
14
|
+
export function AdminAuthWrapper({ children }: { children: ReactNode }) {
|
|
15
|
+
return (
|
|
16
|
+
<AuthProvider checkInterval={30000}>
|
|
17
|
+
{children}
|
|
18
|
+
</AuthProvider>
|
|
19
|
+
)
|
|
20
|
+
}
|