@orion-studios/payload-admin-components 0.2.0-beta.0 → 0.2.0-beta.2

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/dist/index.mjs CHANGED
@@ -1,3 +1,165 @@
1
+ // src/fields/themePreference.ts
2
+ var themePreferenceField = {
3
+ name: "themePreference",
4
+ type: "select",
5
+ defaultValue: "light",
6
+ options: [
7
+ { label: "Light", value: "light" },
8
+ { label: "Dark", value: "dark" },
9
+ { label: "Brand Light", value: "brand-light" },
10
+ { label: "Brand Dark", value: "brand-dark" }
11
+ ],
12
+ admin: {
13
+ position: "sidebar",
14
+ condition: () => false
15
+ // Hidden from form — managed by ThemeSwitcher
16
+ }
17
+ };
18
+
19
+ // src/helpers/configureAdmin.ts
20
+ function configureAdmin(config) {
21
+ const { brandName, brandPrimary, brandSecondary } = config;
22
+ const brandCssVars = [
23
+ brandPrimary ? `--brand-primary: ${brandPrimary};` : "",
24
+ brandSecondary ? `--brand-secondary: ${brandSecondary};` : ""
25
+ ].filter(Boolean).join("\n ");
26
+ return {
27
+ admin: {
28
+ components: {
29
+ graphics: {
30
+ Logo: {
31
+ exportName: "Logo",
32
+ path: "@orion-studios/payload-admin-components/client"
33
+ },
34
+ Icon: {
35
+ exportName: "Icon",
36
+ path: "@orion-studios/payload-admin-components/client"
37
+ }
38
+ },
39
+ views: {
40
+ dashboard: {
41
+ Component: {
42
+ exportName: "Dashboard",
43
+ path: "@orion-studios/payload-admin-components/client"
44
+ }
45
+ }
46
+ },
47
+ providers: [
48
+ {
49
+ exportName: "ThemeProvider",
50
+ path: "@orion-studios/payload-admin-components/client"
51
+ }
52
+ ],
53
+ afterNavLinks: [
54
+ {
55
+ exportName: "ThemeSwitcher",
56
+ path: "@orion-studios/payload-admin-components/client"
57
+ }
58
+ ]
59
+ },
60
+ meta: {
61
+ titleSuffix: ` \u2014 ${brandName}`
62
+ }
63
+ },
64
+ brandName,
65
+ brandPrimary: brandPrimary || "#3b82f6",
66
+ brandSecondary: brandSecondary || "#8b5cf6",
67
+ brandCssVars,
68
+ /**
69
+ * Wraps the Users collection to add theme preference field.
70
+ */
71
+ wrapUsers(usersCollection) {
72
+ return {
73
+ ...usersCollection,
74
+ fields: [...usersCollection.fields || [], themePreferenceField]
75
+ };
76
+ },
77
+ /**
78
+ * Wraps globals with intuitive group labels.
79
+ * Maps common global slugs to the "Site Design" group with user-friendly labels.
80
+ */
81
+ wrapGlobals(globals) {
82
+ const labelMap = {
83
+ header: { group: "Site Design", label: "Header & Navigation" },
84
+ footer: { group: "Site Design", label: "Footer" },
85
+ "site-settings": { group: "Site Design", label: "Website Settings" }
86
+ };
87
+ return globals.map((global) => {
88
+ const mapping = labelMap[global.slug];
89
+ if (!mapping) return global;
90
+ return {
91
+ ...global,
92
+ admin: {
93
+ ...global.admin,
94
+ group: mapping.group
95
+ },
96
+ label: mapping.label
97
+ };
98
+ });
99
+ }
100
+ };
101
+ }
102
+
103
+ // src/helpers/withTooltips.ts
104
+ var defaultTooltips = {
105
+ title: "The main title displayed on this page.",
106
+ slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
107
+ template: "Choose a layout template. This controls the overall structure of the page.",
108
+ parent: "Select a parent page to nest this page under. This affects the URL path.",
109
+ path: "The full URL path for this page. This is automatically generated from the slug and parent.",
110
+ layout: "Add and arrange content sections on your page. Each section is a building block.",
111
+ metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
112
+ metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
113
+ canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
114
+ ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
115
+ noIndex: "When enabled, search engines will not list this page in results.",
116
+ noFollow: "When enabled, search engines will not follow links on this page.",
117
+ publishedAt: "The date and time this page was first published.",
118
+ alt: "Describe this image for screen readers and search engines. Be specific and concise.",
119
+ navItems: "The links shown in your website's navigation menu.",
120
+ copyright: "The copyright text displayed in your website footer.",
121
+ contactEmail: "The email address displayed in your footer and contact sections.",
122
+ contactPhone: "The phone number displayed in your footer and contact sections.",
123
+ siteName: "Your website's name. Appears in browser tabs and search results.",
124
+ tagline: "A short phrase describing your business. Used in SEO and site metadata.",
125
+ canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
126
+ };
127
+ function withTooltips(fields, customTooltips) {
128
+ const tooltips = { ...defaultTooltips, ...customTooltips };
129
+ return fields.map((field) => addTooltipToField(field, tooltips));
130
+ }
131
+ function addTooltipToField(field, tooltips) {
132
+ if ("name" in field && field.name && tooltips[field.name]) {
133
+ const tooltip = tooltips[field.name];
134
+ const admin = field.admin;
135
+ if (!admin?.description) {
136
+ return {
137
+ ...field,
138
+ admin: {
139
+ ...admin,
140
+ description: tooltip
141
+ }
142
+ };
143
+ }
144
+ }
145
+ if ("fields" in field && Array.isArray(field.fields)) {
146
+ return {
147
+ ...field,
148
+ fields: field.fields.map((f) => addTooltipToField(f, tooltips))
149
+ };
150
+ }
151
+ if ("tabs" in field && Array.isArray(field.tabs)) {
152
+ return {
153
+ ...field,
154
+ tabs: field.tabs.map((tab) => ({
155
+ ...tab,
156
+ fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
157
+ }))
158
+ };
159
+ }
160
+ return field;
161
+ }
162
+
1
163
  // src/components/Logo.tsx
2
164
  import { jsx, jsxs } from "react/jsx-runtime";
3
165
  function Logo() {
@@ -1109,168 +1271,6 @@ function WelcomeHeader({
1109
1271
  }
1110
1272
  );
1111
1273
  }
1112
-
1113
- // src/fields/themePreference.ts
1114
- var themePreferenceField = {
1115
- name: "themePreference",
1116
- type: "select",
1117
- defaultValue: "light",
1118
- options: [
1119
- { label: "Light", value: "light" },
1120
- { label: "Dark", value: "dark" },
1121
- { label: "Brand Light", value: "brand-light" },
1122
- { label: "Brand Dark", value: "brand-dark" }
1123
- ],
1124
- admin: {
1125
- position: "sidebar",
1126
- condition: () => false
1127
- // Hidden from form — managed by ThemeSwitcher
1128
- }
1129
- };
1130
-
1131
- // src/helpers/configureAdmin.ts
1132
- function configureAdmin(config) {
1133
- const { brandName, brandPrimary, brandSecondary } = config;
1134
- const brandCssVars = [
1135
- brandPrimary ? `--brand-primary: ${brandPrimary};` : "",
1136
- brandSecondary ? `--brand-secondary: ${brandSecondary};` : ""
1137
- ].filter(Boolean).join("\n ");
1138
- return {
1139
- admin: {
1140
- components: {
1141
- graphics: {
1142
- Logo: {
1143
- exportName: "Logo",
1144
- path: "@orion-studios/payload-admin-components"
1145
- },
1146
- Icon: {
1147
- exportName: "Icon",
1148
- path: "@orion-studios/payload-admin-components"
1149
- }
1150
- },
1151
- views: {
1152
- dashboard: {
1153
- Component: {
1154
- exportName: "Dashboard",
1155
- path: "@orion-studios/payload-admin-components"
1156
- }
1157
- }
1158
- },
1159
- providers: [
1160
- {
1161
- exportName: "ThemeProvider",
1162
- path: "@orion-studios/payload-admin-components"
1163
- }
1164
- ],
1165
- afterNavLinks: [
1166
- {
1167
- exportName: "ThemeSwitcher",
1168
- path: "@orion-studios/payload-admin-components"
1169
- }
1170
- ]
1171
- },
1172
- meta: {
1173
- titleSuffix: ` \u2014 ${brandName}`
1174
- }
1175
- },
1176
- brandName,
1177
- brandPrimary: brandPrimary || "#3b82f6",
1178
- brandSecondary: brandSecondary || "#8b5cf6",
1179
- brandCssVars,
1180
- /**
1181
- * Wraps the Users collection to add theme preference field.
1182
- */
1183
- wrapUsers(usersCollection) {
1184
- return {
1185
- ...usersCollection,
1186
- fields: [...usersCollection.fields || [], themePreferenceField]
1187
- };
1188
- },
1189
- /**
1190
- * Wraps globals with intuitive group labels.
1191
- * Maps common global slugs to the "Site Design" group with user-friendly labels.
1192
- */
1193
- wrapGlobals(globals) {
1194
- const labelMap = {
1195
- header: { group: "Site Design", label: "Header & Navigation" },
1196
- footer: { group: "Site Design", label: "Footer" },
1197
- "site-settings": { group: "Site Design", label: "Website Settings" }
1198
- };
1199
- return globals.map((global) => {
1200
- const mapping = labelMap[global.slug];
1201
- if (!mapping) return global;
1202
- return {
1203
- ...global,
1204
- admin: {
1205
- ...global.admin,
1206
- group: mapping.group
1207
- },
1208
- label: mapping.label
1209
- };
1210
- });
1211
- }
1212
- };
1213
- }
1214
-
1215
- // src/helpers/withTooltips.ts
1216
- var defaultTooltips = {
1217
- title: "The main title displayed on this page.",
1218
- slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
1219
- template: "Choose a layout template. This controls the overall structure of the page.",
1220
- parent: "Select a parent page to nest this page under. This affects the URL path.",
1221
- path: "The full URL path for this page. This is automatically generated from the slug and parent.",
1222
- layout: "Add and arrange content sections on your page. Each section is a building block.",
1223
- metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
1224
- metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
1225
- canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
1226
- ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
1227
- noIndex: "When enabled, search engines will not list this page in results.",
1228
- noFollow: "When enabled, search engines will not follow links on this page.",
1229
- publishedAt: "The date and time this page was first published.",
1230
- alt: "Describe this image for screen readers and search engines. Be specific and concise.",
1231
- navItems: "The links shown in your website's navigation menu.",
1232
- copyright: "The copyright text displayed in your website footer.",
1233
- contactEmail: "The email address displayed in your footer and contact sections.",
1234
- contactPhone: "The phone number displayed in your footer and contact sections.",
1235
- siteName: "Your website's name. Appears in browser tabs and search results.",
1236
- tagline: "A short phrase describing your business. Used in SEO and site metadata.",
1237
- canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
1238
- };
1239
- function withTooltips(fields, customTooltips) {
1240
- const tooltips = { ...defaultTooltips, ...customTooltips };
1241
- return fields.map((field) => addTooltipToField(field, tooltips));
1242
- }
1243
- function addTooltipToField(field, tooltips) {
1244
- if ("name" in field && field.name && tooltips[field.name]) {
1245
- const tooltip = tooltips[field.name];
1246
- const admin = field.admin;
1247
- if (!admin?.description) {
1248
- return {
1249
- ...field,
1250
- admin: {
1251
- ...admin,
1252
- description: tooltip
1253
- }
1254
- };
1255
- }
1256
- }
1257
- if ("fields" in field && Array.isArray(field.fields)) {
1258
- return {
1259
- ...field,
1260
- fields: field.fields.map((f) => addTooltipToField(f, tooltips))
1261
- };
1262
- }
1263
- if ("tabs" in field && Array.isArray(field.tabs)) {
1264
- return {
1265
- ...field,
1266
- tabs: field.tabs.map((tab) => ({
1267
- ...tab,
1268
- fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
1269
- }))
1270
- };
1271
- }
1272
- return field;
1273
- }
1274
1274
  export {
1275
1275
  BlockPicker,
1276
1276
  Dashboard,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-studios/payload-admin-components",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "Custom admin UI components for Payload CMS",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -11,6 +11,11 @@
11
11
  "require": "./dist/index.js",
12
12
  "import": "./dist/index.mjs"
13
13
  },
14
+ "./client": {
15
+ "types": "./dist/client.d.ts",
16
+ "require": "./dist/client.js",
17
+ "import": "./dist/client.mjs"
18
+ },
14
19
  "./admin.css": "./src/styles/admin.css"
15
20
  },
16
21
  "files": [
@@ -18,7 +23,7 @@
18
23
  "src"
19
24
  ],
20
25
  "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts && node -e \"const fs=require('fs'),path=require('path');function copyDir(s,d){fs.mkdirSync(d,{recursive:true});for(const f of fs.readdirSync(s)){const sp=path.join(s,f),dp=path.join(d,f);fs.statSync(sp).isDirectory()?copyDir(sp,dp):fs.copyFileSync(sp,dp)}}copyDir('src/styles','dist/styles');fs.copyFileSync('src/styles/admin.css','dist/admin.css')\"",
26
+ "build": "tsup && node -e \"const fs=require('fs'),path=require('path');function copyDir(s,d){fs.mkdirSync(d,{recursive:true});for(const f of fs.readdirSync(s)){const sp=path.join(s,f),dp=path.join(d,f);fs.statSync(sp).isDirectory()?copyDir(sp,dp):fs.copyFileSync(sp,dp)}}copyDir('src/styles','dist/styles');fs.copyFileSync('src/styles/admin.css','dist/admin.css')\"",
22
27
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
28
  "typecheck": "tsc --noEmit"
24
29
  },
package/src/client.ts ADDED
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+
3
+ // Client-side React components
4
+ export { Logo } from './components/Logo'
5
+ export { Icon } from './components/Icon'
6
+ export { Dashboard } from './components/Dashboard'
7
+ export { ThemeSwitcher, ThemeProvider } from './components/ThemeSwitcher'
8
+ export { HelpTooltip } from './components/HelpTooltip'
9
+ export { StatusBadge } from './components/StatusBadge'
10
+ export { EmptyState } from './components/EmptyState'
11
+ export { BlockPicker } from './components/BlockPicker'
12
+ export { SectionTabs } from './components/SectionTabs'
13
+ export { WelcomeHeader } from './components/WelcomeHeader'
14
+
15
+ // Client-side hooks
16
+ export { useTheme } from './hooks/useTheme'
17
+ export type { ThemeOption } from './hooks/useTheme'
@@ -45,31 +45,31 @@ export function configureAdmin(config: AdminConfig) {
45
45
  graphics: {
46
46
  Logo: {
47
47
  exportName: 'Logo',
48
- path: '@orion-studios/payload-admin-components',
48
+ path: '@orion-studios/payload-admin-components/client',
49
49
  },
50
50
  Icon: {
51
51
  exportName: 'Icon',
52
- path: '@orion-studios/payload-admin-components',
52
+ path: '@orion-studios/payload-admin-components/client',
53
53
  },
54
54
  },
55
55
  views: {
56
56
  dashboard: {
57
57
  Component: {
58
58
  exportName: 'Dashboard',
59
- path: '@orion-studios/payload-admin-components',
59
+ path: '@orion-studios/payload-admin-components/client',
60
60
  },
61
61
  },
62
62
  },
63
63
  providers: [
64
64
  {
65
65
  exportName: 'ThemeProvider',
66
- path: '@orion-studios/payload-admin-components',
66
+ path: '@orion-studios/payload-admin-components/client',
67
67
  },
68
68
  ],
69
69
  afterNavLinks: [
70
70
  {
71
71
  exportName: 'ThemeSwitcher',
72
- path: '@orion-studios/payload-admin-components',
72
+ path: '@orion-studios/payload-admin-components/client',
73
73
  },
74
74
  ],
75
75
  },
package/src/index.ts CHANGED
@@ -1,4 +1,11 @@
1
- // Components
1
+ // Server-safe exports (used in payload.config.ts, collection configs, etc.)
2
+ export { configureAdmin } from './helpers/configureAdmin'
3
+ export type { AdminConfig } from './helpers/configureAdmin'
4
+ export { withTooltips } from './helpers/withTooltips'
5
+ export { themePreferenceField } from './fields/themePreference'
6
+
7
+ // Re-export client components so they can be resolved by Payload's import map
8
+ // These are referenced by path string in configureAdmin, not directly imported
2
9
  export { Logo } from './components/Logo'
3
10
  export { Icon } from './components/Icon'
4
11
  export { Dashboard } from './components/Dashboard'
@@ -9,19 +16,5 @@ export { EmptyState } from './components/EmptyState'
9
16
  export { BlockPicker } from './components/BlockPicker'
10
17
  export { SectionTabs } from './components/SectionTabs'
11
18
  export { WelcomeHeader } from './components/WelcomeHeader'
12
-
13
- // Helpers
14
- export { configureAdmin } from './helpers/configureAdmin'
15
- export type { AdminConfig } from './helpers/configureAdmin'
16
- export { withTooltips } from './helpers/withTooltips'
17
-
18
- // Hooks
19
19
  export { useTheme } from './hooks/useTheme'
20
20
  export type { ThemeOption } from './hooks/useTheme'
21
-
22
- // Fields
23
- export { themePreferenceField } from './fields/themePreference'
24
-
25
- // CSS styles are exported via package.json exports map
26
- // Import in your payload.config.ts:
27
- // css: require.resolve('@orion-studios/payload-admin-components/dist/admin.css')