@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.d.mts CHANGED
@@ -1,6 +1,58 @@
1
+ import { CollectionConfig, GlobalConfig, Field } from 'payload';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
  import { ReactNode } from 'react';
3
- import { CollectionConfig, GlobalConfig, Field } from 'payload';
4
+
5
+ interface AdminConfig {
6
+ brandName: string;
7
+ brandPrimary?: string;
8
+ brandSecondary?: string;
9
+ logoUrl?: string;
10
+ }
11
+ declare function configureAdmin(config: AdminConfig): {
12
+ admin: {
13
+ components: {
14
+ graphics: {
15
+ Logo: {
16
+ exportName: string;
17
+ path: string;
18
+ };
19
+ Icon: {
20
+ exportName: string;
21
+ path: string;
22
+ };
23
+ };
24
+ views: {
25
+ dashboard: {
26
+ Component: {
27
+ exportName: string;
28
+ path: string;
29
+ };
30
+ };
31
+ };
32
+ providers: {
33
+ exportName: string;
34
+ path: string;
35
+ }[];
36
+ afterNavLinks: {
37
+ exportName: string;
38
+ path: string;
39
+ }[];
40
+ };
41
+ meta: {
42
+ titleSuffix: string;
43
+ };
44
+ };
45
+ brandName: string;
46
+ brandPrimary: string;
47
+ brandSecondary: string;
48
+ brandCssVars: string;
49
+ wrapUsers(usersCollection: CollectionConfig): CollectionConfig;
50
+ wrapGlobals(globals: GlobalConfig[]): GlobalConfig[];
51
+ };
52
+
53
+ declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
54
+
55
+ declare const themePreferenceField: Field;
4
56
 
5
57
  declare function Logo(): react_jsx_runtime.JSX.Element;
6
58
 
@@ -61,56 +113,6 @@ declare function WelcomeHeader({ title, description, tooltip, actions, }: {
61
113
  actions?: React.ReactNode;
62
114
  }): react_jsx_runtime.JSX.Element;
63
115
 
64
- interface AdminConfig {
65
- brandName: string;
66
- brandPrimary?: string;
67
- brandSecondary?: string;
68
- logoUrl?: string;
69
- }
70
- declare function configureAdmin(config: AdminConfig): {
71
- admin: {
72
- components: {
73
- graphics: {
74
- Logo: {
75
- exportName: string;
76
- path: string;
77
- };
78
- Icon: {
79
- exportName: string;
80
- path: string;
81
- };
82
- };
83
- views: {
84
- dashboard: {
85
- Component: {
86
- exportName: string;
87
- path: string;
88
- };
89
- };
90
- };
91
- providers: {
92
- exportName: string;
93
- path: string;
94
- }[];
95
- afterNavLinks: {
96
- exportName: string;
97
- path: string;
98
- }[];
99
- };
100
- meta: {
101
- titleSuffix: string;
102
- };
103
- };
104
- brandName: string;
105
- brandPrimary: string;
106
- brandSecondary: string;
107
- brandCssVars: string;
108
- wrapUsers(usersCollection: CollectionConfig): CollectionConfig;
109
- wrapGlobals(globals: GlobalConfig[]): GlobalConfig[];
110
- };
111
-
112
- declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
113
-
114
116
  type ThemeOption = 'light' | 'dark' | 'brand-light' | 'brand-dark';
115
117
  declare function useTheme(): {
116
118
  theme: ThemeOption;
@@ -122,6 +124,4 @@ declare function useTheme(): {
122
124
  toggleBrandMode: () => void;
123
125
  };
124
126
 
125
- declare const themePreferenceField: Field;
126
-
127
127
  export { type AdminConfig, BlockPicker, Dashboard, EmptyState, HelpTooltip, Icon, Logo, SectionTabs, StatusBadge, type ThemeOption, ThemeProvider, ThemeSwitcher, WelcomeHeader, configureAdmin, themePreferenceField, useTheme, withTooltips };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,58 @@
1
+ import { CollectionConfig, GlobalConfig, Field } from 'payload';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
  import { ReactNode } from 'react';
3
- import { CollectionConfig, GlobalConfig, Field } from 'payload';
4
+
5
+ interface AdminConfig {
6
+ brandName: string;
7
+ brandPrimary?: string;
8
+ brandSecondary?: string;
9
+ logoUrl?: string;
10
+ }
11
+ declare function configureAdmin(config: AdminConfig): {
12
+ admin: {
13
+ components: {
14
+ graphics: {
15
+ Logo: {
16
+ exportName: string;
17
+ path: string;
18
+ };
19
+ Icon: {
20
+ exportName: string;
21
+ path: string;
22
+ };
23
+ };
24
+ views: {
25
+ dashboard: {
26
+ Component: {
27
+ exportName: string;
28
+ path: string;
29
+ };
30
+ };
31
+ };
32
+ providers: {
33
+ exportName: string;
34
+ path: string;
35
+ }[];
36
+ afterNavLinks: {
37
+ exportName: string;
38
+ path: string;
39
+ }[];
40
+ };
41
+ meta: {
42
+ titleSuffix: string;
43
+ };
44
+ };
45
+ brandName: string;
46
+ brandPrimary: string;
47
+ brandSecondary: string;
48
+ brandCssVars: string;
49
+ wrapUsers(usersCollection: CollectionConfig): CollectionConfig;
50
+ wrapGlobals(globals: GlobalConfig[]): GlobalConfig[];
51
+ };
52
+
53
+ declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
54
+
55
+ declare const themePreferenceField: Field;
4
56
 
5
57
  declare function Logo(): react_jsx_runtime.JSX.Element;
6
58
 
@@ -61,56 +113,6 @@ declare function WelcomeHeader({ title, description, tooltip, actions, }: {
61
113
  actions?: React.ReactNode;
62
114
  }): react_jsx_runtime.JSX.Element;
63
115
 
64
- interface AdminConfig {
65
- brandName: string;
66
- brandPrimary?: string;
67
- brandSecondary?: string;
68
- logoUrl?: string;
69
- }
70
- declare function configureAdmin(config: AdminConfig): {
71
- admin: {
72
- components: {
73
- graphics: {
74
- Logo: {
75
- exportName: string;
76
- path: string;
77
- };
78
- Icon: {
79
- exportName: string;
80
- path: string;
81
- };
82
- };
83
- views: {
84
- dashboard: {
85
- Component: {
86
- exportName: string;
87
- path: string;
88
- };
89
- };
90
- };
91
- providers: {
92
- exportName: string;
93
- path: string;
94
- }[];
95
- afterNavLinks: {
96
- exportName: string;
97
- path: string;
98
- }[];
99
- };
100
- meta: {
101
- titleSuffix: string;
102
- };
103
- };
104
- brandName: string;
105
- brandPrimary: string;
106
- brandSecondary: string;
107
- brandCssVars: string;
108
- wrapUsers(usersCollection: CollectionConfig): CollectionConfig;
109
- wrapGlobals(globals: GlobalConfig[]): GlobalConfig[];
110
- };
111
-
112
- declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
113
-
114
116
  type ThemeOption = 'light' | 'dark' | 'brand-light' | 'brand-dark';
115
117
  declare function useTheme(): {
116
118
  theme: ThemeOption;
@@ -122,6 +124,4 @@ declare function useTheme(): {
122
124
  toggleBrandMode: () => void;
123
125
  };
124
126
 
125
- declare const themePreferenceField: Field;
126
-
127
127
  export { type AdminConfig, BlockPicker, Dashboard, EmptyState, HelpTooltip, Icon, Logo, SectionTabs, StatusBadge, type ThemeOption, ThemeProvider, ThemeSwitcher, WelcomeHeader, configureAdmin, themePreferenceField, useTheme, withTooltips };
package/dist/index.js CHANGED
@@ -38,6 +38,168 @@ __export(index_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(index_exports);
40
40
 
41
+ // src/fields/themePreference.ts
42
+ var themePreferenceField = {
43
+ name: "themePreference",
44
+ type: "select",
45
+ defaultValue: "light",
46
+ options: [
47
+ { label: "Light", value: "light" },
48
+ { label: "Dark", value: "dark" },
49
+ { label: "Brand Light", value: "brand-light" },
50
+ { label: "Brand Dark", value: "brand-dark" }
51
+ ],
52
+ admin: {
53
+ position: "sidebar",
54
+ condition: () => false
55
+ // Hidden from form — managed by ThemeSwitcher
56
+ }
57
+ };
58
+
59
+ // src/helpers/configureAdmin.ts
60
+ function configureAdmin(config) {
61
+ const { brandName, brandPrimary, brandSecondary } = config;
62
+ const brandCssVars = [
63
+ brandPrimary ? `--brand-primary: ${brandPrimary};` : "",
64
+ brandSecondary ? `--brand-secondary: ${brandSecondary};` : ""
65
+ ].filter(Boolean).join("\n ");
66
+ return {
67
+ admin: {
68
+ components: {
69
+ graphics: {
70
+ Logo: {
71
+ exportName: "Logo",
72
+ path: "@orion-studios/payload-admin-components/client"
73
+ },
74
+ Icon: {
75
+ exportName: "Icon",
76
+ path: "@orion-studios/payload-admin-components/client"
77
+ }
78
+ },
79
+ views: {
80
+ dashboard: {
81
+ Component: {
82
+ exportName: "Dashboard",
83
+ path: "@orion-studios/payload-admin-components/client"
84
+ }
85
+ }
86
+ },
87
+ providers: [
88
+ {
89
+ exportName: "ThemeProvider",
90
+ path: "@orion-studios/payload-admin-components/client"
91
+ }
92
+ ],
93
+ afterNavLinks: [
94
+ {
95
+ exportName: "ThemeSwitcher",
96
+ path: "@orion-studios/payload-admin-components/client"
97
+ }
98
+ ]
99
+ },
100
+ meta: {
101
+ titleSuffix: ` \u2014 ${brandName}`
102
+ }
103
+ },
104
+ brandName,
105
+ brandPrimary: brandPrimary || "#3b82f6",
106
+ brandSecondary: brandSecondary || "#8b5cf6",
107
+ brandCssVars,
108
+ /**
109
+ * Wraps the Users collection to add theme preference field.
110
+ */
111
+ wrapUsers(usersCollection) {
112
+ return {
113
+ ...usersCollection,
114
+ fields: [...usersCollection.fields || [], themePreferenceField]
115
+ };
116
+ },
117
+ /**
118
+ * Wraps globals with intuitive group labels.
119
+ * Maps common global slugs to the "Site Design" group with user-friendly labels.
120
+ */
121
+ wrapGlobals(globals) {
122
+ const labelMap = {
123
+ header: { group: "Site Design", label: "Header & Navigation" },
124
+ footer: { group: "Site Design", label: "Footer" },
125
+ "site-settings": { group: "Site Design", label: "Website Settings" }
126
+ };
127
+ return globals.map((global) => {
128
+ const mapping = labelMap[global.slug];
129
+ if (!mapping) return global;
130
+ return {
131
+ ...global,
132
+ admin: {
133
+ ...global.admin,
134
+ group: mapping.group
135
+ },
136
+ label: mapping.label
137
+ };
138
+ });
139
+ }
140
+ };
141
+ }
142
+
143
+ // src/helpers/withTooltips.ts
144
+ var defaultTooltips = {
145
+ title: "The main title displayed on this page.",
146
+ slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
147
+ template: "Choose a layout template. This controls the overall structure of the page.",
148
+ parent: "Select a parent page to nest this page under. This affects the URL path.",
149
+ path: "The full URL path for this page. This is automatically generated from the slug and parent.",
150
+ layout: "Add and arrange content sections on your page. Each section is a building block.",
151
+ metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
152
+ metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
153
+ canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
154
+ ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
155
+ noIndex: "When enabled, search engines will not list this page in results.",
156
+ noFollow: "When enabled, search engines will not follow links on this page.",
157
+ publishedAt: "The date and time this page was first published.",
158
+ alt: "Describe this image for screen readers and search engines. Be specific and concise.",
159
+ navItems: "The links shown in your website's navigation menu.",
160
+ copyright: "The copyright text displayed in your website footer.",
161
+ contactEmail: "The email address displayed in your footer and contact sections.",
162
+ contactPhone: "The phone number displayed in your footer and contact sections.",
163
+ siteName: "Your website's name. Appears in browser tabs and search results.",
164
+ tagline: "A short phrase describing your business. Used in SEO and site metadata.",
165
+ canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
166
+ };
167
+ function withTooltips(fields, customTooltips) {
168
+ const tooltips = { ...defaultTooltips, ...customTooltips };
169
+ return fields.map((field) => addTooltipToField(field, tooltips));
170
+ }
171
+ function addTooltipToField(field, tooltips) {
172
+ if ("name" in field && field.name && tooltips[field.name]) {
173
+ const tooltip = tooltips[field.name];
174
+ const admin = field.admin;
175
+ if (!admin?.description) {
176
+ return {
177
+ ...field,
178
+ admin: {
179
+ ...admin,
180
+ description: tooltip
181
+ }
182
+ };
183
+ }
184
+ }
185
+ if ("fields" in field && Array.isArray(field.fields)) {
186
+ return {
187
+ ...field,
188
+ fields: field.fields.map((f) => addTooltipToField(f, tooltips))
189
+ };
190
+ }
191
+ if ("tabs" in field && Array.isArray(field.tabs)) {
192
+ return {
193
+ ...field,
194
+ tabs: field.tabs.map((tab) => ({
195
+ ...tab,
196
+ fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
197
+ }))
198
+ };
199
+ }
200
+ return field;
201
+ }
202
+
41
203
  // src/components/Logo.tsx
42
204
  var import_jsx_runtime = require("react/jsx-runtime");
43
205
  function Logo() {
@@ -1149,168 +1311,6 @@ function WelcomeHeader({
1149
1311
  }
1150
1312
  );
1151
1313
  }
1152
-
1153
- // src/fields/themePreference.ts
1154
- var themePreferenceField = {
1155
- name: "themePreference",
1156
- type: "select",
1157
- defaultValue: "light",
1158
- options: [
1159
- { label: "Light", value: "light" },
1160
- { label: "Dark", value: "dark" },
1161
- { label: "Brand Light", value: "brand-light" },
1162
- { label: "Brand Dark", value: "brand-dark" }
1163
- ],
1164
- admin: {
1165
- position: "sidebar",
1166
- condition: () => false
1167
- // Hidden from form — managed by ThemeSwitcher
1168
- }
1169
- };
1170
-
1171
- // src/helpers/configureAdmin.ts
1172
- function configureAdmin(config) {
1173
- const { brandName, brandPrimary, brandSecondary } = config;
1174
- const brandCssVars = [
1175
- brandPrimary ? `--brand-primary: ${brandPrimary};` : "",
1176
- brandSecondary ? `--brand-secondary: ${brandSecondary};` : ""
1177
- ].filter(Boolean).join("\n ");
1178
- return {
1179
- admin: {
1180
- components: {
1181
- graphics: {
1182
- Logo: {
1183
- exportName: "Logo",
1184
- path: "@orion-studios/payload-admin-components"
1185
- },
1186
- Icon: {
1187
- exportName: "Icon",
1188
- path: "@orion-studios/payload-admin-components"
1189
- }
1190
- },
1191
- views: {
1192
- dashboard: {
1193
- Component: {
1194
- exportName: "Dashboard",
1195
- path: "@orion-studios/payload-admin-components"
1196
- }
1197
- }
1198
- },
1199
- providers: [
1200
- {
1201
- exportName: "ThemeProvider",
1202
- path: "@orion-studios/payload-admin-components"
1203
- }
1204
- ],
1205
- afterNavLinks: [
1206
- {
1207
- exportName: "ThemeSwitcher",
1208
- path: "@orion-studios/payload-admin-components"
1209
- }
1210
- ]
1211
- },
1212
- meta: {
1213
- titleSuffix: ` \u2014 ${brandName}`
1214
- }
1215
- },
1216
- brandName,
1217
- brandPrimary: brandPrimary || "#3b82f6",
1218
- brandSecondary: brandSecondary || "#8b5cf6",
1219
- brandCssVars,
1220
- /**
1221
- * Wraps the Users collection to add theme preference field.
1222
- */
1223
- wrapUsers(usersCollection) {
1224
- return {
1225
- ...usersCollection,
1226
- fields: [...usersCollection.fields || [], themePreferenceField]
1227
- };
1228
- },
1229
- /**
1230
- * Wraps globals with intuitive group labels.
1231
- * Maps common global slugs to the "Site Design" group with user-friendly labels.
1232
- */
1233
- wrapGlobals(globals) {
1234
- const labelMap = {
1235
- header: { group: "Site Design", label: "Header & Navigation" },
1236
- footer: { group: "Site Design", label: "Footer" },
1237
- "site-settings": { group: "Site Design", label: "Website Settings" }
1238
- };
1239
- return globals.map((global) => {
1240
- const mapping = labelMap[global.slug];
1241
- if (!mapping) return global;
1242
- return {
1243
- ...global,
1244
- admin: {
1245
- ...global.admin,
1246
- group: mapping.group
1247
- },
1248
- label: mapping.label
1249
- };
1250
- });
1251
- }
1252
- };
1253
- }
1254
-
1255
- // src/helpers/withTooltips.ts
1256
- var defaultTooltips = {
1257
- title: "The main title displayed on this page.",
1258
- slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
1259
- template: "Choose a layout template. This controls the overall structure of the page.",
1260
- parent: "Select a parent page to nest this page under. This affects the URL path.",
1261
- path: "The full URL path for this page. This is automatically generated from the slug and parent.",
1262
- layout: "Add and arrange content sections on your page. Each section is a building block.",
1263
- metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
1264
- metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
1265
- canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
1266
- ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
1267
- noIndex: "When enabled, search engines will not list this page in results.",
1268
- noFollow: "When enabled, search engines will not follow links on this page.",
1269
- publishedAt: "The date and time this page was first published.",
1270
- alt: "Describe this image for screen readers and search engines. Be specific and concise.",
1271
- navItems: "The links shown in your website's navigation menu.",
1272
- copyright: "The copyright text displayed in your website footer.",
1273
- contactEmail: "The email address displayed in your footer and contact sections.",
1274
- contactPhone: "The phone number displayed in your footer and contact sections.",
1275
- siteName: "Your website's name. Appears in browser tabs and search results.",
1276
- tagline: "A short phrase describing your business. Used in SEO and site metadata.",
1277
- canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
1278
- };
1279
- function withTooltips(fields, customTooltips) {
1280
- const tooltips = { ...defaultTooltips, ...customTooltips };
1281
- return fields.map((field) => addTooltipToField(field, tooltips));
1282
- }
1283
- function addTooltipToField(field, tooltips) {
1284
- if ("name" in field && field.name && tooltips[field.name]) {
1285
- const tooltip = tooltips[field.name];
1286
- const admin = field.admin;
1287
- if (!admin?.description) {
1288
- return {
1289
- ...field,
1290
- admin: {
1291
- ...admin,
1292
- description: tooltip
1293
- }
1294
- };
1295
- }
1296
- }
1297
- if ("fields" in field && Array.isArray(field.fields)) {
1298
- return {
1299
- ...field,
1300
- fields: field.fields.map((f) => addTooltipToField(f, tooltips))
1301
- };
1302
- }
1303
- if ("tabs" in field && Array.isArray(field.tabs)) {
1304
- return {
1305
- ...field,
1306
- tabs: field.tabs.map((tab) => ({
1307
- ...tab,
1308
- fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
1309
- }))
1310
- };
1311
- }
1312
- return field;
1313
- }
1314
1314
  // Annotate the CommonJS export names for ESM import in node:
1315
1315
  0 && (module.exports = {
1316
1316
  BlockPicker,