@bison-lab/payload-core 3.9.0 → 3.11.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 +16 -9
- package/dist/admin.d.mts +34 -13
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +726 -371
- package/dist/admin.mjs.map +1 -1
- package/dist/identity-DZOb3_Gk.mjs +383 -0
- package/dist/identity-DZOb3_Gk.mjs.map +1 -0
- package/dist/index.d.mts +30 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +285 -196
- package/dist/index.mjs.map +1 -1
- package/dist/{map-BUDkX8g1.mjs → looks-BbL309kO.mjs} +94 -6
- package/dist/looks-BbL309kO.mjs.map +1 -0
- package/dist/{library-BGq4wGif.d.mts → looks-DsizRfFV.d.mts} +62 -8
- package/dist/looks-DsizRfFV.d.mts.map +1 -0
- package/dist/react.mjs +28 -3
- package/dist/react.mjs.map +1 -1
- package/dist/theme.d.mts +11 -2
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +40 -4
- package/dist/theme.mjs.map +1 -1
- package/package.json +4 -3
- package/dist/identity-D1X0Om4Z.mjs +0 -198
- package/dist/identity-D1X0Om4Z.mjs.map +0 -1
- package/dist/library-BGq4wGif.d.mts.map +0 -1
- package/dist/map-BUDkX8g1.mjs.map +0 -1
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { DESTRUCTIVE_SCALE_HEX, SHADE_STEPS, createColorScale, generateColorScale, includedShadeSteps, isThemeHex } from "@bison-lab/tokens";
|
|
2
|
+
//#region src/theme/fields.ts
|
|
3
|
+
const THEME_COLOR_FIELD = "@bison-lab/payload-core/admin#ColorField";
|
|
4
|
+
const THEME_COLOR_SCALE_FIELD = "@bison-lab/payload-core/admin#ColorScaleField";
|
|
5
|
+
const THEME_LIBRARY_FIELD = "@bison-lab/payload-core/admin#LibraryField";
|
|
6
|
+
const THEME_FONT_FIELD = "@bison-lab/payload-core/admin#FontField";
|
|
7
|
+
const THEME_PAIRING_FIELD = "@bison-lab/payload-core/admin#PairingField";
|
|
8
|
+
const THEME_APPEARANCE_FIELD = "@bison-lab/payload-core/admin#AppearanceField";
|
|
9
|
+
const THEME_GREY_SCALE_FIELD = "@bison-lab/payload-core/admin#GreyScaleField";
|
|
10
|
+
const THEME_CONTRAST_REPORT = "@bison-lab/payload-core/admin#ContrastReport";
|
|
11
|
+
const THEME_SECTION_HEADING = "@bison-lab/payload-core/admin#SectionHeading";
|
|
12
|
+
const THEME_PUBLISH_FIELD = "@bison-lab/payload-core/admin#PublishChild";
|
|
13
|
+
const THEME_SAVE_BUTTON = "@bison-lab/payload-core/admin#HiddenSaveButton";
|
|
14
|
+
const THEME_DOCUMENT_CONTROLS = "@bison-lab/payload-core/admin#ThemeDocumentControls";
|
|
15
|
+
const THEME_IDENTITY_FALLBACK = "@bison-lab/payload-core/admin#IdentityFallback";
|
|
16
|
+
const LOOK_FIELD = "@bison-lab/payload-core/admin#LookField";
|
|
17
|
+
function headingSelectValue(heading) {
|
|
18
|
+
return heading ?? "";
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/theme/map.ts
|
|
22
|
+
function pick(value, fallback) {
|
|
23
|
+
return value == null ? fallback : value;
|
|
24
|
+
}
|
|
25
|
+
function headingFromDoc(heading, seed) {
|
|
26
|
+
if (heading === void 0) return seed;
|
|
27
|
+
if (heading === null || heading === "") return null;
|
|
28
|
+
return heading;
|
|
29
|
+
}
|
|
30
|
+
function hexFromColor(value, fallback) {
|
|
31
|
+
if (typeof value === "string") return value || fallback;
|
|
32
|
+
return pick(value?.hex, fallback);
|
|
33
|
+
}
|
|
34
|
+
function colorDocFromHex(hex, sourceStep = 500) {
|
|
35
|
+
return colorDocFromState(createColorScale(hex, sourceStep));
|
|
36
|
+
}
|
|
37
|
+
function colorDocFromState(state) {
|
|
38
|
+
return {
|
|
39
|
+
hex: state.hex,
|
|
40
|
+
sourceStep: state.sourceStep,
|
|
41
|
+
scale: state.scale,
|
|
42
|
+
stale: state.stale,
|
|
43
|
+
include: Array.isArray(state.include) ? "custom" : state.include,
|
|
44
|
+
includedSteps: Array.isArray(state.include) ? [...state.include] : void 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function stateFromColorDoc(doc, fallbackHex = "#000000") {
|
|
48
|
+
const hex = isThemeHex(doc?.hex) ? doc.hex : fallbackHex;
|
|
49
|
+
const sourceStep = Number(doc?.sourceStep) || 500;
|
|
50
|
+
const include = includeFromDoc(doc, sourceStep);
|
|
51
|
+
return {
|
|
52
|
+
hex,
|
|
53
|
+
sourceStep,
|
|
54
|
+
scale: doc?.scale && typeof doc.scale === "object" ? doc.scale : generateColorScale(hex, sourceStep),
|
|
55
|
+
stale: Boolean(doc?.stale),
|
|
56
|
+
include
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function includeFromDoc(doc, sourceStep) {
|
|
60
|
+
if (doc?.include === "source") return "source";
|
|
61
|
+
if (doc?.include === "custom" && Array.isArray(doc.includedSteps)) {
|
|
62
|
+
const steps = doc.includedSteps.map(Number).filter((step) => SHADE_STEPS.includes(step));
|
|
63
|
+
if (!steps.includes(sourceStep)) steps.push(sourceStep);
|
|
64
|
+
return steps;
|
|
65
|
+
}
|
|
66
|
+
return "all";
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Nested Theme document → flat `ThemeConfig`. Null or missing editor
|
|
70
|
+
* fields take the seed; `darkSelector` and `fontWeights` always come from
|
|
71
|
+
* the seed. Reads the BIS-87 groups and the pre-BIS-87 flat fields.
|
|
72
|
+
*/
|
|
73
|
+
function themeConfigFromDoc(doc, seed) {
|
|
74
|
+
const brand = doc?.colors?.brand ?? doc?.brand;
|
|
75
|
+
const typography = doc?.typography ?? doc?.fonts;
|
|
76
|
+
const appearance = doc?.appearance;
|
|
77
|
+
return {
|
|
78
|
+
brandPrimary: hexFromColor(brand?.primary, seed.brandPrimary),
|
|
79
|
+
brandSecondary: hexFromColor(brand?.secondary, seed.brandSecondary),
|
|
80
|
+
brandAccent: hexFromColor(brand?.accent, seed.brandAccent),
|
|
81
|
+
brandHighlight: hexFromColor(brand?.highlight, seed.brandHighlight),
|
|
82
|
+
brandSuccess: hexFromColor(brand?.success, seed.brandSuccess),
|
|
83
|
+
brandDestructive: hexFromColor(brand?.destructive, seed.brandDestructive ?? DESTRUCTIVE_SCALE_HEX) || seed.brandDestructive || DESTRUCTIVE_SCALE_HEX,
|
|
84
|
+
greyScale: pick(doc?.colors?.greyScale ?? doc?.greyScale, seed.greyScale),
|
|
85
|
+
radius: pick(appearance?.radius ?? doc?.radius, seed.radius),
|
|
86
|
+
shadow: pick(appearance?.shadow ?? doc?.shadow, seed.shadow),
|
|
87
|
+
motion: pick(appearance?.motion ?? doc?.motion, seed.motion),
|
|
88
|
+
density: pick(appearance?.density ?? doc?.density, seed.density),
|
|
89
|
+
defaultTheme: pick(appearance?.defaultTheme ?? doc?.defaultTheme, seed.defaultTheme),
|
|
90
|
+
fontBody: pick(typography?.body, seed.fontBody),
|
|
91
|
+
fontHeading: headingFromDoc(typography?.heading, seed.fontHeading),
|
|
92
|
+
darkSelector: seed.darkSelector,
|
|
93
|
+
fontWeights: seed.fontWeights
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** The document `seedTheme` writes so a fresh Global matches the seed config. */
|
|
97
|
+
function docFromConfig(config, destructive) {
|
|
98
|
+
const destructiveHex = destructive ?? config.brandDestructive ?? DESTRUCTIVE_SCALE_HEX;
|
|
99
|
+
return {
|
|
100
|
+
colors: {
|
|
101
|
+
brand: {
|
|
102
|
+
primary: colorDocFromHex(config.brandPrimary),
|
|
103
|
+
secondary: colorDocFromHex(config.brandSecondary),
|
|
104
|
+
accent: colorDocFromHex(config.brandAccent),
|
|
105
|
+
highlight: colorDocFromHex(config.brandHighlight),
|
|
106
|
+
success: colorDocFromHex(config.brandSuccess),
|
|
107
|
+
destructive: colorDocFromHex(destructiveHex)
|
|
108
|
+
},
|
|
109
|
+
library: [],
|
|
110
|
+
greyScale: config.greyScale
|
|
111
|
+
},
|
|
112
|
+
typography: {
|
|
113
|
+
body: config.fontBody,
|
|
114
|
+
heading: config.fontHeading
|
|
115
|
+
},
|
|
116
|
+
appearance: {
|
|
117
|
+
defaultTheme: config.defaultTheme,
|
|
118
|
+
radius: config.radius,
|
|
119
|
+
shadow: config.shadow,
|
|
120
|
+
motion: config.motion,
|
|
121
|
+
density: config.density
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function validateThemeHex(value) {
|
|
126
|
+
if (!isThemeHex(value)) return "Enter a six-digit hex colour like #1e3a5f";
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
function validateSourceIncluded(value, { siblingData }) {
|
|
130
|
+
const include = siblingData?.include;
|
|
131
|
+
if (include === "all" || include === "source") return true;
|
|
132
|
+
const source = Number(siblingData?.sourceStep);
|
|
133
|
+
const steps = Array.isArray(value) ? value.map(Number) : [];
|
|
134
|
+
if (!SHADE_STEPS.includes(source)) return true;
|
|
135
|
+
if (!steps.includes(source)) return "The source step cannot be excluded";
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/theme/types.ts
|
|
140
|
+
const THEME_SLUG = "theme";
|
|
141
|
+
const THEME_COLORS_SLUG = "theme-colors";
|
|
142
|
+
const THEME_TYPOGRAPHY_SLUG = "theme-typography";
|
|
143
|
+
const THEME_APPEARANCE_SLUG = "theme-appearance";
|
|
144
|
+
const THEME_IDENTITY_SLUG = "theme-identity";
|
|
145
|
+
const SYSTEM_COLOR_KEYS = [
|
|
146
|
+
"primary",
|
|
147
|
+
"secondary",
|
|
148
|
+
"accent",
|
|
149
|
+
"highlight",
|
|
150
|
+
"success",
|
|
151
|
+
"destructive"
|
|
152
|
+
];
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/theme/library.ts
|
|
155
|
+
/**
|
|
156
|
+
* Payload's array form state stores the row count (`0`, `2`, …), not the
|
|
157
|
+
* rows. A custom Field that treats that number as the list will throw
|
|
158
|
+
* `rows.filter is not a function` on an empty Theme library.
|
|
159
|
+
*/
|
|
160
|
+
function asLibraryRows(value) {
|
|
161
|
+
return Array.isArray(value) ? value : [];
|
|
162
|
+
}
|
|
163
|
+
const STEP_SET = new Set(SHADE_STEPS);
|
|
164
|
+
/**
|
|
165
|
+
* Page editors pick `coral-400`, never a raw hex. Rewrite every use of
|
|
166
|
+
* `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.
|
|
167
|
+
* A bare key (`coral`) becomes `toKey`. Anything else is left alone.
|
|
168
|
+
*/
|
|
169
|
+
function rewriteColorToken(token, fromKey, toKey) {
|
|
170
|
+
if (token === fromKey) return toKey;
|
|
171
|
+
const dash = token.lastIndexOf("-");
|
|
172
|
+
if (dash <= 0) return token;
|
|
173
|
+
const key = token.slice(0, dash);
|
|
174
|
+
const step = Number(token.slice(dash + 1));
|
|
175
|
+
if (key !== fromKey || !STEP_SET.has(step)) return token;
|
|
176
|
+
return `${toKey}-${step}`;
|
|
177
|
+
}
|
|
178
|
+
function themeColorKeys(doc) {
|
|
179
|
+
const custom = asLibraryRows(doc?.colors?.library).map((row) => row.key?.trim()).filter((key) => Boolean(key));
|
|
180
|
+
return [...SYSTEM_COLOR_KEYS, ...custom];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Remove a custom color. Unused: omit `replacement` and the row is gone.
|
|
184
|
+
* In use: pass another system or custom key; the caller rewrites page
|
|
185
|
+
* tokens with `rewriteColorToken`. After this, no library row still
|
|
186
|
+
* has `key`.
|
|
187
|
+
*/
|
|
188
|
+
function deleteLibraryColor(doc, key, replacement) {
|
|
189
|
+
const library = [...asLibraryRows(doc.colors?.library)];
|
|
190
|
+
const index = library.findIndex((row) => row.key === key);
|
|
191
|
+
if (index === -1) throw new Error(`No custom color named ${JSON.stringify(key)}`);
|
|
192
|
+
library.splice(index, 1);
|
|
193
|
+
const next = {
|
|
194
|
+
...doc,
|
|
195
|
+
colors: {
|
|
196
|
+
...doc.colors,
|
|
197
|
+
library
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
if (replacement !== void 0) {
|
|
201
|
+
if (replacement === key) throw new Error("Replacement must be a different color");
|
|
202
|
+
if (!themeColorKeys(next).includes(replacement)) throw new Error(`Replacement ${JSON.stringify(replacement)} is not a system or remaining custom color`);
|
|
203
|
+
}
|
|
204
|
+
return next;
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/theme/looks.ts
|
|
208
|
+
/**
|
|
209
|
+
* System colors Color Settings offers as page-editor fills. Success and
|
|
210
|
+
* Destructive stay off this list — they are theme chrome only.
|
|
211
|
+
*/
|
|
212
|
+
const PAGE_EDITOR_SYSTEM_KEYS = [
|
|
213
|
+
"primary",
|
|
214
|
+
"secondary",
|
|
215
|
+
"accent",
|
|
216
|
+
"highlight"
|
|
217
|
+
];
|
|
218
|
+
const SYSTEM_LABELS = {
|
|
219
|
+
primary: "Primary",
|
|
220
|
+
secondary: "Secondary",
|
|
221
|
+
accent: "Accent",
|
|
222
|
+
highlight: "Highlight"
|
|
223
|
+
};
|
|
224
|
+
function brandColor(doc, key) {
|
|
225
|
+
const value = (doc?.colors?.brand ?? doc?.brand)?.[key];
|
|
226
|
+
if (typeof value === "string" || value == null) return value == null ? null : { hex: value };
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
function themeLibraryFromDoc(doc) {
|
|
230
|
+
return Array.isArray(doc?.colors?.library) ? doc.colors.library : [];
|
|
231
|
+
}
|
|
232
|
+
function libraryRows(doc) {
|
|
233
|
+
return themeLibraryFromDoc(doc);
|
|
234
|
+
}
|
|
235
|
+
function titleCase(key) {
|
|
236
|
+
return key.charAt(0).toUpperCase() + key.slice(1);
|
|
237
|
+
}
|
|
238
|
+
function stepsFor(color, fallbackHex) {
|
|
239
|
+
return includedShadeSteps(stateFromColorDoc(color, fallbackHex));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Family keys a `lookField()` may offer: the page-editor system scales
|
|
243
|
+
* plus every custom color on Colors. Adding Coral on Theme makes `coral`
|
|
244
|
+
* appear here with no `@bison-lab/*` release.
|
|
245
|
+
*/
|
|
246
|
+
function pageEditorLooks(doc) {
|
|
247
|
+
const system = PAGE_EDITOR_SYSTEM_KEYS.map((value) => ({
|
|
248
|
+
label: SYSTEM_LABELS[value],
|
|
249
|
+
value
|
|
250
|
+
}));
|
|
251
|
+
const custom = libraryRows(doc).map((row) => {
|
|
252
|
+
const value = row.key?.trim();
|
|
253
|
+
if (!value) return null;
|
|
254
|
+
return {
|
|
255
|
+
label: row.label?.trim() || titleCase(value),
|
|
256
|
+
value
|
|
257
|
+
};
|
|
258
|
+
}).filter((option) => option !== null);
|
|
259
|
+
return [...system, ...custom];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Included steps as `coral-400`. Excluded steps do not appear. System
|
|
263
|
+
* scales with no stored include list offer the full 50–950 ramp.
|
|
264
|
+
*/
|
|
265
|
+
function pageEditorTokens(doc) {
|
|
266
|
+
const tokens = [];
|
|
267
|
+
for (const key of PAGE_EDITOR_SYSTEM_KEYS) {
|
|
268
|
+
const label = SYSTEM_LABELS[key];
|
|
269
|
+
for (const step of stepsFor(brandColor(doc, key), "#000000")) tokens.push({
|
|
270
|
+
label: `${label} ${step}`,
|
|
271
|
+
value: `${key}-${step}`
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
for (const row of libraryRows(doc)) {
|
|
275
|
+
const key = row.key?.trim();
|
|
276
|
+
if (!key) continue;
|
|
277
|
+
const label = row.label?.trim() || titleCase(key);
|
|
278
|
+
for (const step of stepsFor(row, row.hex ?? "#000000")) tokens.push({
|
|
279
|
+
label: `${label} ${step}`,
|
|
280
|
+
value: `${key}-${step}`
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return tokens;
|
|
284
|
+
}
|
|
285
|
+
async function themeDocFromRequest(req) {
|
|
286
|
+
try {
|
|
287
|
+
return await req.payload?.findGlobal?.({
|
|
288
|
+
slug: "theme",
|
|
289
|
+
depth: 0,
|
|
290
|
+
overrideAccess: true
|
|
291
|
+
}) ?? null;
|
|
292
|
+
} catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/theme/look-field.ts
|
|
298
|
+
const validateLook = async (value, { req }) => {
|
|
299
|
+
if (value == null || value === "") return true;
|
|
300
|
+
if (typeof value !== "string") return "Pick a look from Theme → Colors";
|
|
301
|
+
if (pageEditorLooks(await themeDocFromRequest(req)).some((look) => look.value === value)) return true;
|
|
302
|
+
return "Pick a look from Theme → Colors";
|
|
303
|
+
};
|
|
304
|
+
const validateColorToken = async (value, { req }) => {
|
|
305
|
+
if (value == null || value === "") return true;
|
|
306
|
+
if (typeof value !== "string") return "Pick an included step from Theme → Colors";
|
|
307
|
+
if (pageEditorTokens(await themeDocFromRequest(req)).some((token) => token.value === value)) return true;
|
|
308
|
+
return "Pick an included step from Theme → Colors";
|
|
309
|
+
};
|
|
310
|
+
function pickerField(defaults, overrides) {
|
|
311
|
+
const { name = defaults.name, label = defaults.label, admin, required, validate = defaults.validate } = overrides;
|
|
312
|
+
return {
|
|
313
|
+
name,
|
|
314
|
+
type: "text",
|
|
315
|
+
label,
|
|
316
|
+
required,
|
|
317
|
+
validate,
|
|
318
|
+
admin: {
|
|
319
|
+
...admin,
|
|
320
|
+
components: {
|
|
321
|
+
Field: LOOK_FIELD,
|
|
322
|
+
...admin?.components
|
|
323
|
+
},
|
|
324
|
+
custom: {
|
|
325
|
+
mode: defaults.mode,
|
|
326
|
+
...admin?.custom
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* A picker any collection or global can offer. Options come from the
|
|
333
|
+
* published Theme at request time: page-editor system scales plus custom
|
|
334
|
+
* Colors. Payload select options are a static list, so this is a text
|
|
335
|
+
* field with an admin picker — adding Coral does not need a schema change.
|
|
336
|
+
*/
|
|
337
|
+
function lookField(overrides = {}) {
|
|
338
|
+
return pickerField({
|
|
339
|
+
name: "look",
|
|
340
|
+
label: "Look",
|
|
341
|
+
mode: "look",
|
|
342
|
+
validate: validateLook
|
|
343
|
+
}, overrides);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Included steps as `coral-400`. Excluded steps do not appear.
|
|
347
|
+
*/
|
|
348
|
+
function colorTokenField(overrides = {}) {
|
|
349
|
+
return pickerField({
|
|
350
|
+
name: "color",
|
|
351
|
+
label: "Color",
|
|
352
|
+
mode: "token",
|
|
353
|
+
validate: validateColorToken
|
|
354
|
+
}, overrides);
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/theme/identity.ts
|
|
358
|
+
function fromUpload(value, fallback) {
|
|
359
|
+
if (value && typeof value === "object") {
|
|
360
|
+
const upload = value;
|
|
361
|
+
if (upload.url) return {
|
|
362
|
+
url: upload.url,
|
|
363
|
+
alt: upload.alt ?? fallback?.alt ?? ""
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
return fallback ?? null;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Uploaded logo, favicon, and mobile-menu mark, or the fallback the site
|
|
370
|
+
* passed into `createTheme`. Empty fields keep the fallback;
|
|
371
|
+
* `--color-primary-mark` is not a Theme field.
|
|
372
|
+
*/
|
|
373
|
+
function resolveThemeIdentity(doc, fallback) {
|
|
374
|
+
return {
|
|
375
|
+
lockup: fromUpload(doc?.logo, fallback?.lockup),
|
|
376
|
+
mark: fromUpload(doc?.logoMark, fallback?.mark),
|
|
377
|
+
favicon: fromUpload(doc?.favicon, fallback?.favicon)
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
export { THEME_IDENTITY_FALLBACK as A, THEME_APPEARANCE_FIELD as C, THEME_DOCUMENT_CONTROLS as D, THEME_CONTRAST_REPORT as E, THEME_SECTION_HEADING as F, headingSelectValue as I, THEME_PAIRING_FIELD as M, THEME_PUBLISH_FIELD as N, THEME_FONT_FIELD as O, THEME_SAVE_BUTTON as P, LOOK_FIELD as S, THEME_COLOR_SCALE_FIELD as T, docFromConfig as _, pageEditorLooks as a, validateSourceIncluded as b, deleteLibraryColor as c, SYSTEM_COLOR_KEYS as d, THEME_APPEARANCE_SLUG as f, THEME_TYPOGRAPHY_SLUG as g, THEME_SLUG as h, PAGE_EDITOR_SYSTEM_KEYS as i, THEME_LIBRARY_FIELD as j, THEME_GREY_SCALE_FIELD as k, rewriteColorToken as l, THEME_IDENTITY_SLUG as m, colorTokenField as n, pageEditorTokens as o, THEME_COLORS_SLUG as p, lookField as r, themeLibraryFromDoc as s, resolveThemeIdentity as t, themeColorKeys as u, stateFromColorDoc as v, THEME_COLOR_FIELD as w, validateThemeHex as x, themeConfigFromDoc as y };
|
|
382
|
+
|
|
383
|
+
//# sourceMappingURL=identity-DZOb3_Gk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-DZOb3_Gk.mjs","names":[],"sources":["../src/theme/fields.ts","../src/theme/map.ts","../src/theme/types.ts","../src/theme/library.ts","../src/theme/looks.ts","../src/theme/look-field.ts","../src/theme/identity.ts"],"sourcesContent":["import type { ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { EditableTheme } from \"./types\";\n\nexport const THEME_COLOR_FIELD = \"@bison-lab/payload-core/admin#ColorField\";\nexport const THEME_COLOR_SCALE_FIELD = \"@bison-lab/payload-core/admin#ColorScaleField\";\nexport const THEME_LIBRARY_FIELD = \"@bison-lab/payload-core/admin#LibraryField\";\nexport const THEME_FONT_FIELD = \"@bison-lab/payload-core/admin#FontField\";\nexport const THEME_PAIRING_FIELD = \"@bison-lab/payload-core/admin#PairingField\";\nexport const THEME_APPEARANCE_FIELD = \"@bison-lab/payload-core/admin#AppearanceField\";\nexport const THEME_GREY_SCALE_FIELD = \"@bison-lab/payload-core/admin#GreyScaleField\";\nexport const THEME_CONTRAST_REPORT = \"@bison-lab/payload-core/admin#ContrastReport\";\nexport const THEME_SECTION_HEADING = \"@bison-lab/payload-core/admin#SectionHeading\";\nexport const THEME_PUBLISH_FIELD = \"@bison-lab/payload-core/admin#PublishChild\";\nexport const THEME_SAVE_BUTTON = \"@bison-lab/payload-core/admin#HiddenSaveButton\";\nexport const THEME_DOCUMENT_CONTROLS = \"@bison-lab/payload-core/admin#ThemeDocumentControls\";\nexport const THEME_IDENTITY_FALLBACK = \"@bison-lab/payload-core/admin#IdentityFallback\";\nexport const LOOK_FIELD = \"@bison-lab/payload-core/admin#LookField\";\n\n/**\n * Document path for each editable `ThemeConfig` key. Locked with `satisfies`\n * so a new config field without a Theme field (or the reverse) fails at\n * compile time. `darkSelector` and `fontWeights` are seed-only.\n */\nexport const THEME_FIELD_PATHS = {\n brandPrimary: \"colors.brand.primary.hex\",\n brandSecondary: \"colors.brand.secondary.hex\",\n brandAccent: \"colors.brand.accent.hex\",\n brandHighlight: \"colors.brand.highlight.hex\",\n brandSuccess: \"colors.brand.success.hex\",\n brandDestructive: \"colors.brand.destructive.hex\",\n greyScale: \"colors.greyScale\",\n defaultTheme: \"appearance.defaultTheme\",\n radius: \"appearance.radius\",\n shadow: \"appearance.shadow\",\n motion: \"appearance.motion\",\n density: \"appearance.density\",\n fontBody: \"typography.body\",\n fontHeading: \"typography.heading\",\n} as const satisfies Record<keyof EditableTheme, string>;\n\nexport type ThemeFieldPath = (typeof THEME_FIELD_PATHS)[keyof typeof THEME_FIELD_PATHS];\n\n/** Empty select value for heading: same family as body. */\nexport const SAME_AS_BODY = \"\";\n\nexport function headingSelectValue(heading: ThemeConfig[\"fontHeading\"]): string {\n return heading ?? SAME_AS_BODY;\n}\n","import {\n createColorScale,\n DESTRUCTIVE_SCALE_HEX,\n generateColorScale,\n isThemeHex,\n SHADE_STEPS,\n type ColorScale,\n type ColorScaleInclude,\n type ColorScaleState,\n type ShadeStep,\n type ThemeConfig,\n} from \"@bison-lab/tokens\";\n\nimport { SAME_AS_BODY } from \"./fields\";\nimport type { ThemeColorDoc, ThemeDoc } from \"./types\";\n\nfunction pick<T>(value: T | null | undefined, fallback: T): T {\n return value == null ? fallback : value;\n}\n\nfunction headingFromDoc(\n heading: string | null | undefined,\n seed: ThemeConfig[\"fontHeading\"],\n): string | null {\n if (heading === undefined) return seed;\n if (heading === null || heading === SAME_AS_BODY) return null;\n return heading;\n}\n\nfunction hexFromColor(value: ThemeColorDoc | string | null | undefined, fallback: string): string {\n if (typeof value === \"string\") return value || fallback;\n return pick(value?.hex, fallback);\n}\n\nexport function colorDocFromHex(hex: string, sourceStep: ShadeStep = 500): ThemeColorDoc {\n return colorDocFromState(createColorScale(hex, sourceStep));\n}\n\nexport function colorDocFromState(state: ColorScaleState): ThemeColorDoc {\n return {\n hex: state.hex,\n sourceStep: state.sourceStep,\n scale: state.scale,\n stale: state.stale,\n include: Array.isArray(state.include) ? \"custom\" : state.include,\n includedSteps: Array.isArray(state.include) ? [...state.include] : undefined,\n };\n}\n\nexport function stateFromColorDoc(\n doc: ThemeColorDoc | null | undefined,\n fallbackHex = \"#000000\",\n): ColorScaleState {\n const hex = isThemeHex(doc?.hex) ? doc.hex : fallbackHex;\n const sourceStep = (Number(doc?.sourceStep) || 500) as ShadeStep;\n const include = includeFromDoc(doc, sourceStep);\n const scale =\n doc?.scale && typeof doc.scale === \"object\" ? (doc.scale as ColorScale) : generateColorScale(hex, sourceStep);\n return { hex, sourceStep, scale, stale: Boolean(doc?.stale), include };\n}\n\nfunction includeFromDoc(doc: ThemeColorDoc | null | undefined, sourceStep: ShadeStep): ColorScaleInclude {\n if (doc?.include === \"source\") return \"source\";\n if (doc?.include === \"custom\" && Array.isArray(doc.includedSteps)) {\n const steps = doc.includedSteps.map(Number).filter((step): step is ShadeStep => SHADE_STEPS.includes(step as ShadeStep));\n if (!steps.includes(sourceStep)) steps.push(sourceStep);\n return steps;\n }\n return \"all\";\n}\n\n/**\n * Nested Theme document → flat `ThemeConfig`. Null or missing editor\n * fields take the seed; `darkSelector` and `fontWeights` always come from\n * the seed. Reads the BIS-87 groups and the pre-BIS-87 flat fields.\n */\nexport function themeConfigFromDoc(doc: ThemeDoc | null | undefined, seed: ThemeConfig): ThemeConfig {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const typography = doc?.typography ?? doc?.fonts;\n const appearance = doc?.appearance;\n return {\n brandPrimary: hexFromColor(brand?.primary, seed.brandPrimary),\n brandSecondary: hexFromColor(brand?.secondary, seed.brandSecondary),\n brandAccent: hexFromColor(brand?.accent, seed.brandAccent),\n brandHighlight: hexFromColor(brand?.highlight, seed.brandHighlight),\n brandSuccess: hexFromColor(brand?.success, seed.brandSuccess),\n brandDestructive:\n hexFromColor(brand?.destructive, seed.brandDestructive ?? DESTRUCTIVE_SCALE_HEX) ||\n seed.brandDestructive ||\n DESTRUCTIVE_SCALE_HEX,\n greyScale: pick(doc?.colors?.greyScale ?? doc?.greyScale, seed.greyScale),\n radius: pick(appearance?.radius ?? doc?.radius, seed.radius),\n shadow: pick(appearance?.shadow ?? doc?.shadow, seed.shadow),\n motion: pick(appearance?.motion ?? doc?.motion, seed.motion),\n density: pick(appearance?.density ?? doc?.density, seed.density),\n defaultTheme: pick(appearance?.defaultTheme ?? doc?.defaultTheme, seed.defaultTheme),\n fontBody: pick(typography?.body, seed.fontBody),\n fontHeading: headingFromDoc(typography?.heading, seed.fontHeading),\n darkSelector: seed.darkSelector,\n fontWeights: seed.fontWeights,\n };\n}\n\n/** The document `seedTheme` writes so a fresh Global matches the seed config. */\nexport function docFromConfig(config: ThemeConfig, destructive?: string): ThemeDoc {\n const destructiveHex = destructive ?? config.brandDestructive ?? DESTRUCTIVE_SCALE_HEX;\n return {\n colors: {\n brand: {\n primary: colorDocFromHex(config.brandPrimary),\n secondary: colorDocFromHex(config.brandSecondary),\n accent: colorDocFromHex(config.brandAccent),\n highlight: colorDocFromHex(config.brandHighlight),\n success: colorDocFromHex(config.brandSuccess),\n destructive: colorDocFromHex(destructiveHex),\n },\n library: [],\n greyScale: config.greyScale,\n },\n typography: {\n body: config.fontBody,\n heading: config.fontHeading,\n },\n appearance: {\n defaultTheme: config.defaultTheme,\n radius: config.radius,\n shadow: config.shadow,\n motion: config.motion,\n density: config.density,\n },\n };\n}\n\nexport function validateThemeHex(value: unknown): true | string {\n if (!isThemeHex(value)) return \"Enter a six-digit hex colour like #1e3a5f\";\n return true;\n}\n\nexport function validateSourceIncluded(\n value: unknown,\n { siblingData }: { siblingData?: { sourceStep?: unknown; include?: unknown } },\n): true | string {\n const include = siblingData?.include;\n if (include === \"all\" || include === \"source\") return true;\n const source = Number(siblingData?.sourceStep);\n const steps = Array.isArray(value) ? value.map(Number) : [];\n if (!SHADE_STEPS.includes(source as ShadeStep)) return true;\n if (!steps.includes(source)) return \"The source step cannot be excluded\";\n return true;\n}\n","import type { Access } from \"payload\";\nimport type { FontEntry } from \"@bison-lab/fonts\";\nimport type { ColorScale, ColorScaleInclude, ShadeStep, ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { ResolvedThemeIdentity, ThemeIdentityFallback } from \"./identity\";\n\n/**\n * The Theme document a site's generated types will describe. Optional and\n * nullable, no index signature: a generated Global is assignable to this,\n * never the reverse.\n *\n * Legacy flat `brand.*` hexes, `fonts`, and preset fields at the root stay\n * readable so `getPublishedTheme` still maps a pre-BIS-87 row.\n */\nexport interface ThemeColorDoc {\n hex?: string | null;\n sourceStep?: ShadeStep | string | null;\n scale?: ColorScale | null;\n stale?: boolean | null;\n include?: ColorScaleInclude | \"custom\" | null;\n includedSteps?: ShadeStep[] | string[] | null;\n}\n\nexport interface ThemeLibraryColorDoc extends ThemeColorDoc {\n key?: string | null;\n label?: string | null;\n}\n\nexport interface ThemeDoc {\n colors?: {\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n library?: ThemeLibraryColorDoc[] | null;\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n } | null;\n typography?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n appearance?: {\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n } | null;\n /** @deprecated Pre-BIS-87 flat brand hexes. */\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n /** @deprecated Pre-BIS-87; now `colors.greyScale`. */\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n /** @deprecated Pre-BIS-87; now `appearance.*`. */\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n /** @deprecated Pre-BIS-87; now `typography`. */\n fonts?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n logo?: number | string | ThemeUploadDoc | null;\n favicon?: number | string | ThemeUploadDoc | null;\n logoMark?: number | string | ThemeUploadDoc | null;\n}\n\nexport interface ThemeUploadDoc {\n id?: number | string | null;\n url?: string | null;\n alt?: string | null;\n}\n\n/**\n * What an editor can change. `darkSelector` and `fontWeights` stay on the\n * seed — they mean nothing in the admin — and `themeConfigFromDoc` puts\n * them back.\n */\nexport type EditableTheme = Omit<ThemeConfig, \"darkSelector\" | \"fontWeights\">;\n\nexport interface CreateThemeOptions {\n /**\n * Required, no default. Predicates live in each site's `src/platform`\n * until BIS-43; pass `canManageBrand` as `update` (and typically\n * `isAuthenticated` as `read`).\n */\n access: { read: Access; update: Access };\n /** The site's `bison.config.json`. Every field's `defaultValue`, and the fallback `getPublishedTheme` returns. */\n seed: ThemeConfig;\n /**\n * Destructive seed hex. Falls back to `seed.brandDestructive`, then\n * the library's `DESTRUCTIVE_SCALE_HEX` (`#ef4444`).\n */\n destructive?: string;\n /** Default: the whole catalogue. */\n fonts?: readonly FontEntry[];\n /** Where the site's `serveFont` route answers, for the picker's specimens. Default `\"/fonts\"`. */\n fontsBaseUrl?: string;\n /** Fill + automatic label target. Default `7`. Warnings never block save. */\n contrastTarget?: number;\n /**\n * @deprecated Theme has no preview pane (SPI-56 canceled). Kept so a\n * site that still passes it does not fail to boot.\n */\n previewPath?: string;\n /**\n * Adds the Identity page (logo, favicon, mobile-menu mark) when given.\n * Pass `BRAND_ASSETS_SLUG` (or the slug you gave `createBrandAssets`).\n * Save on that page writes only those uploads onto the stored Theme row.\n */\n logo?: { collection: string };\n /**\n * Fallback art when logo, favicon, or mobile-menu mark is empty. The\n * site passes today's files; `--color-primary-mark` is not a Theme field.\n */\n identity?: { fallback?: ThemeIdentityFallback };\n /** Fires from `afterChange` on every save — Theme has no draft mode. */\n onPublish?: (theme: ThemeConfig, doc: ThemeDoc) => void | Promise<void>;\n}\n\nexport interface ThemeHeadOptions {\n fontsBaseUrl?: string;\n attribute?: \"class\" | \"data-theme\";\n identity?: ResolvedThemeIdentity;\n /**\n * Custom Colors rows. `themeHead` emits their 50–950 variables and\n * `[data-look]` bindings so a picker key paints without a package bump.\n */\n library?: ThemeLibraryColorDoc[] | null;\n}\n\nexport interface ThemeHead {\n css: string;\n preloads: { href: string; type: \"font/woff2\" }[];\n identity?: ResolvedThemeIdentity;\n}\n\nexport const THEME_SLUG = \"theme\";\nexport const THEME_COLORS_SLUG = \"theme-colors\";\nexport const THEME_TYPOGRAPHY_SLUG = \"theme-typography\";\nexport const THEME_APPEARANCE_SLUG = \"theme-appearance\";\nexport const THEME_IDENTITY_SLUG = \"theme-identity\";\n\nexport const SYSTEM_COLOR_KEYS = [\n \"primary\",\n \"secondary\",\n \"accent\",\n \"highlight\",\n \"success\",\n \"destructive\",\n] as const;\n\nexport type SystemColorKey = (typeof SYSTEM_COLOR_KEYS)[number];\n","import { SHADE_STEPS, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { SYSTEM_COLOR_KEYS, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * Payload's array form state stores the row count (`0`, `2`, …), not the\n * rows. A custom Field that treats that number as the list will throw\n * `rows.filter is not a function` on an empty Theme library.\n */\nexport function asLibraryRows(value: unknown): ThemeLibraryColorDoc[] {\n return Array.isArray(value) ? value : [];\n}\n\nconst STEP_SET = new Set<number>(SHADE_STEPS);\n\n/**\n * Page editors pick `coral-400`, never a raw hex. Rewrite every use of\n * `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.\n * A bare key (`coral`) becomes `toKey`. Anything else is left alone.\n */\nexport function rewriteColorToken(token: string, fromKey: string, toKey: string): string {\n if (token === fromKey) return toKey;\n const dash = token.lastIndexOf(\"-\");\n if (dash <= 0) return token;\n const key = token.slice(0, dash);\n const step = Number(token.slice(dash + 1));\n if (key !== fromKey || !STEP_SET.has(step)) return token;\n return `${toKey}-${step as ShadeStep}`;\n}\n\nexport function themeColorKeys(doc: ThemeDoc | null | undefined): string[] {\n const custom = asLibraryRows(doc?.colors?.library)\n .map((row) => row.key?.trim())\n .filter((key): key is string => Boolean(key));\n return [...SYSTEM_COLOR_KEYS, ...custom];\n}\n\n/**\n * Remove a custom color. Unused: omit `replacement` and the row is gone.\n * In use: pass another system or custom key; the caller rewrites page\n * tokens with `rewriteColorToken`. After this, no library row still\n * has `key`.\n */\nexport function deleteLibraryColor(doc: ThemeDoc, key: string, replacement?: string): ThemeDoc {\n const library = [...asLibraryRows(doc.colors?.library)];\n const index = library.findIndex((row) => row.key === key);\n if (index === -1) {\n throw new Error(`No custom color named ${JSON.stringify(key)}`);\n }\n library.splice(index, 1);\n const next: ThemeDoc = {\n ...doc,\n colors: { ...doc.colors, library },\n };\n if (replacement !== undefined) {\n if (replacement === key) {\n throw new Error(\"Replacement must be a different color\");\n }\n if (!themeColorKeys(next).includes(replacement)) {\n throw new Error(`Replacement ${JSON.stringify(replacement)} is not a system or remaining custom color`);\n }\n }\n return next;\n}\n","import { includedShadeSteps, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { stateFromColorDoc } from \"./map\";\nimport { THEME_SLUG, type ThemeColorDoc, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * System colors Color Settings offers as page-editor fills. Success and\n * Destructive stay off this list — they are theme chrome only.\n */\nexport const PAGE_EDITOR_SYSTEM_KEYS = [\"primary\", \"secondary\", \"accent\", \"highlight\"] as const;\n\nexport type PageEditorSystemKey = (typeof PAGE_EDITOR_SYSTEM_KEYS)[number];\n\nexport interface LookOption {\n label: string;\n value: string;\n}\n\nconst SYSTEM_LABELS: Record<PageEditorSystemKey, string> = {\n primary: \"Primary\",\n secondary: \"Secondary\",\n accent: \"Accent\",\n highlight: \"Highlight\",\n};\n\nfunction brandColor(doc: ThemeDoc | null | undefined, key: PageEditorSystemKey): ThemeColorDoc | null {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const value = brand?.[key];\n if (typeof value === \"string\" || value == null) return value == null ? null : { hex: value };\n return value;\n}\n\nexport function themeLibraryFromDoc(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return Array.isArray(doc?.colors?.library) ? doc.colors.library : [];\n}\n\nfunction libraryRows(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return themeLibraryFromDoc(doc);\n}\n\nfunction titleCase(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1);\n}\n\nfunction stepsFor(color: ThemeColorDoc | null | undefined, fallbackHex: string): ShadeStep[] {\n return includedShadeSteps(stateFromColorDoc(color, fallbackHex));\n}\n\n/**\n * Family keys a `lookField()` may offer: the page-editor system scales\n * plus every custom color on Colors. Adding Coral on Theme makes `coral`\n * appear here with no `@bison-lab/*` release.\n */\nexport function pageEditorLooks(doc: ThemeDoc | null | undefined): LookOption[] {\n const system = PAGE_EDITOR_SYSTEM_KEYS.map((value) => ({\n label: SYSTEM_LABELS[value],\n value,\n }));\n const custom = libraryRows(doc)\n .map((row) => {\n const value = row.key?.trim();\n if (!value) return null;\n return { label: row.label?.trim() || titleCase(value), value };\n })\n .filter((option): option is LookOption => option !== null);\n return [...system, ...custom];\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear. System\n * scales with no stored include list offer the full 50–950 ramp.\n */\nexport function pageEditorTokens(doc: ThemeDoc | null | undefined): LookOption[] {\n const tokens: LookOption[] = [];\n for (const key of PAGE_EDITOR_SYSTEM_KEYS) {\n const label = SYSTEM_LABELS[key];\n for (const step of stepsFor(brandColor(doc, key), \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n for (const row of libraryRows(doc)) {\n const key = row.key?.trim();\n if (!key) continue;\n const label = row.label?.trim() || titleCase(key);\n for (const step of stepsFor(row, row.hex ?? \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n return tokens;\n}\n\nexport async function themeDocFromRequest(req: {\n payload?: {\n findGlobal?: (args: {\n slug: string;\n depth?: number;\n overrideAccess?: boolean;\n }) => Promise<ThemeDoc | null | undefined>;\n };\n}): Promise<ThemeDoc | null> {\n try {\n const doc = await req.payload?.findGlobal?.({\n slug: THEME_SLUG,\n depth: 0,\n overrideAccess: true,\n });\n return doc ?? null;\n } catch {\n return null;\n }\n}\n","import type { StaticLabel, TextField, TextFieldSingleValidation } from \"payload\";\n\nimport { LOOK_FIELD } from \"./fields\";\nimport { pageEditorLooks, pageEditorTokens, themeDocFromRequest } from \"./looks\";\n\nexport interface LookFieldOptions {\n name?: string;\n label?: StaticLabel;\n required?: boolean;\n admin?: TextField[\"admin\"];\n validate?: TextFieldSingleValidation;\n}\n\nexport type LookFieldMode = \"look\" | \"token\";\n\nexport const validateLook: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick a look from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorLooks(doc).some((look) => look.value === value)) return true;\n return \"Pick a look from Theme → Colors\";\n};\n\nexport const validateColorToken: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick an included step from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorTokens(doc).some((token) => token.value === value)) return true;\n return \"Pick an included step from Theme → Colors\";\n};\n\nfunction pickerField(\n defaults: { name: string; label: string; mode: LookFieldMode; validate: TextFieldSingleValidation },\n overrides: LookFieldOptions,\n): TextField {\n const { name = defaults.name, label = defaults.label, admin, required, validate = defaults.validate } = overrides;\n return {\n name,\n type: \"text\",\n label,\n required,\n validate,\n admin: {\n ...admin,\n components: { Field: LOOK_FIELD, ...admin?.components },\n custom: { mode: defaults.mode, ...admin?.custom },\n },\n };\n}\n\n/**\n * A picker any collection or global can offer. Options come from the\n * published Theme at request time: page-editor system scales plus custom\n * Colors. Payload select options are a static list, so this is a text\n * field with an admin picker — adding Coral does not need a schema change.\n */\nexport function lookField(overrides: LookFieldOptions = {}): TextField {\n return pickerField({ name: \"look\", label: \"Look\", mode: \"look\", validate: validateLook }, overrides);\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear.\n */\nexport function colorTokenField(overrides: LookFieldOptions = {}): TextField {\n return pickerField(\n { name: \"color\", label: \"Color\", mode: \"token\", validate: validateColorToken },\n overrides,\n );\n}\n","import type { ThemeDoc, ThemeUploadDoc } from \"./types\";\n\nexport interface ThemeIdentityAsset {\n url: string;\n alt: string;\n}\n\nexport interface ThemeIdentityFallback {\n lockup?: ThemeIdentityAsset;\n mark?: ThemeIdentityAsset;\n favicon?: ThemeIdentityAsset;\n}\n\nexport interface ResolvedThemeIdentity {\n lockup: ThemeIdentityAsset | null;\n mark: ThemeIdentityAsset | null;\n favicon: ThemeIdentityAsset | null;\n}\n\nfunction fromUpload(value: ThemeDoc[\"logo\"], fallback?: ThemeIdentityAsset): ThemeIdentityAsset | null {\n if (value && typeof value === \"object\") {\n const upload = value as ThemeUploadDoc;\n if (upload.url) {\n return { url: upload.url, alt: upload.alt ?? fallback?.alt ?? \"\" };\n }\n }\n return fallback ?? null;\n}\n\n/**\n * Uploaded logo, favicon, and mobile-menu mark, or the fallback the site\n * passed into `createTheme`. Empty fields keep the fallback;\n * `--color-primary-mark` is not a Theme field.\n */\nexport function resolveThemeIdentity(\n doc: ThemeDoc | null | undefined,\n fallback?: ThemeIdentityFallback,\n): ResolvedThemeIdentity {\n return {\n lockup: fromUpload(doc?.logo, fallback?.lockup),\n mark: fromUpload(doc?.logoMark, fallback?.mark),\n favicon: fromUpload(doc?.favicon, fallback?.favicon),\n };\n}\n"],"mappings":";;AAIA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,yBAAyB;AACtC,MAAa,yBAAyB;AACtC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;AACnC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AACvC,MAAa,aAAa;AA6B1B,SAAgB,mBAAmB,SAA6C;AAC9E,QAAO,WAAA;;;;AC/BT,SAAS,KAAQ,OAA6B,UAAgB;AAC5D,QAAO,SAAS,OAAO,WAAW;;AAGpC,SAAS,eACP,SACA,MACe;AACf,KAAI,YAAY,KAAA,EAAW,QAAO;AAClC,KAAI,YAAY,QAAQ,YAAA,GAA0B,QAAO;AACzD,QAAO;;AAGT,SAAS,aAAa,OAAkD,UAA0B;AAChG,KAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,QAA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AAK;EAC/C,SAAS,WAAW,KAAK,SAAS,UAAU,QAAQ;EACrD"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SeoImageSize, i as SeoImageDoc, n as titleTemplate, o as SeoImageValue, r as MediaId, s as SeoMeta, t as documentTitle } from "./title-B2-gWQZd.mjs";
|
|
2
|
-
import { _ as
|
|
2
|
+
import { A as ThemeIdentityFallback, C as ThemeColorDoc, D as ThemeLibraryColorDoc, O as ThemeUploadDoc, S as THEME_TYPOGRAPHY_SLUG, _ as SystemColorKey, a as pageEditorTokens, b as THEME_IDENTITY_SLUG, c as LookFieldOptions, d as deleteLibraryColor, f as rewriteColorToken, g as SYSTEM_COLOR_KEYS, h as EditableTheme, i as pageEditorLooks, j as resolveThemeIdentity, k as ResolvedThemeIdentity, l as colorTokenField, m as CreateThemeOptions, n as PAGE_EDITOR_SYSTEM_KEYS, o as themeLibraryFromDoc, p as themeColorKeys, r as PageEditorSystemKey, s as LookFieldMode, t as LookOption, u as lookField, v as THEME_APPEARANCE_SLUG, w as ThemeDoc, x as THEME_SLUG, y as THEME_COLORS_SLUG } from "./looks-DsizRfFV.mjs";
|
|
3
3
|
import { ThemeConfig } from "@bison-lab/tokens";
|
|
4
4
|
import { Access, CheckboxField, CollectionConfig, CollectionSlug, GlobalConfig, Plugin, UploadCollectionSlug } from "payload";
|
|
5
5
|
|
|
@@ -106,11 +106,14 @@ declare function truncateAtWord(text: string, max?: number): string;
|
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/theme/global.d.ts
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
109
|
+
* Standard Payload Globals in an `admin.group: "Theme"` nav section —
|
|
110
|
+
* the same pattern as Content and Settings. Each page is its own Global
|
|
111
|
+
* (Save, fields, access). A hidden `theme` store is the published read
|
|
112
|
+
* model `getPublishedTheme` already knows. Locking is off: these are
|
|
113
|
+
* settings forms, not collaborative documents. No draft mode, no preview
|
|
114
|
+
* pane.
|
|
112
115
|
*/
|
|
113
|
-
declare function createTheme(options: CreateThemeOptions): GlobalConfig;
|
|
116
|
+
declare function createTheme(options: CreateThemeOptions): GlobalConfig[];
|
|
114
117
|
//#endregion
|
|
115
118
|
//#region src/brand-assets/collection.d.ts
|
|
116
119
|
declare const BRAND_ASSETS_SLUG = "brand-assets";
|
|
@@ -193,6 +196,24 @@ type ThemeChild = (typeof THEME_CHILDREN)[number];
|
|
|
193
196
|
* the seed.
|
|
194
197
|
*/
|
|
195
198
|
declare function publishThemeChild(stored: ThemeDoc, incoming: ThemeDoc, child: ThemeChild): ThemeDoc;
|
|
199
|
+
interface ThemeStorePayload {
|
|
200
|
+
findGlobal: (args: {
|
|
201
|
+
slug: string;
|
|
202
|
+
draft?: boolean;
|
|
203
|
+
depth?: number;
|
|
204
|
+
overrideAccess?: boolean;
|
|
205
|
+
}) => Promise<ThemeDoc | null | undefined>;
|
|
206
|
+
updateGlobal: (args: {
|
|
207
|
+
slug: string;
|
|
208
|
+
data: ThemeDoc;
|
|
209
|
+
draft?: boolean;
|
|
210
|
+
}) => Promise<unknown>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Save on a Theme page writes that slice onto the hidden `theme` row.
|
|
214
|
+
* Other children stay as stored.
|
|
215
|
+
*/
|
|
216
|
+
declare function persistThemeChild(payload: ThemeStorePayload, incoming: ThemeDoc, child: ThemeChild): Promise<ThemeDoc>;
|
|
196
217
|
//#endregion
|
|
197
218
|
//#region src/theme/fields.d.ts
|
|
198
219
|
declare const THEME_COLOR_FIELD = "@bison-lab/payload-core/admin#ColorField";
|
|
@@ -206,6 +227,9 @@ declare const THEME_CONTRAST_REPORT = "@bison-lab/payload-core/admin#ContrastRep
|
|
|
206
227
|
declare const THEME_SECTION_HEADING = "@bison-lab/payload-core/admin#SectionHeading";
|
|
207
228
|
declare const THEME_PUBLISH_FIELD = "@bison-lab/payload-core/admin#PublishChild";
|
|
208
229
|
declare const THEME_SAVE_BUTTON = "@bison-lab/payload-core/admin#HiddenSaveButton";
|
|
230
|
+
declare const THEME_DOCUMENT_CONTROLS = "@bison-lab/payload-core/admin#ThemeDocumentControls";
|
|
231
|
+
declare const THEME_IDENTITY_FALLBACK = "@bison-lab/payload-core/admin#IdentityFallback";
|
|
232
|
+
declare const LOOK_FIELD = "@bison-lab/payload-core/admin#LookField";
|
|
209
233
|
//#endregion
|
|
210
|
-
export { BRAND_ASSETS_MIME_TYPES, BRAND_ASSETS_SLUG, type CreateBrandAssetsOptions, type CreateThemeOptions, DESCRIPTION_LENGTH, type EditableTheme, type MediaId, type ResolvedThemeIdentity, SHARE_IMAGE_SIZE, SYSTEM_COLOR_KEYS, type SeoDoc, type SeoImageDoc, type SeoImageSize, type SeoImageValue, type SeoMeta, type SeoPluginOptions, type SystemColorKey, THEME_APPEARANCE_FIELD, THEME_COLOR_FIELD, THEME_COLOR_SCALE_FIELD, THEME_CONTRAST_REPORT, THEME_FONT_FIELD, THEME_GREY_SCALE_FIELD, THEME_LIBRARY_FIELD, THEME_PAIRING_FIELD, THEME_PREVIEW_BREAKPOINTS, THEME_PUBLISH_FIELD, THEME_SAVE_BUTTON, THEME_SECTION_HEADING, THEME_SLUG, type ThemeChild, type ThemeColorDoc, type ThemeDoc, type ThemeIdentityFallback, type ThemeLibraryColorDoc, type ThemeUploadDoc, createBrandAssets, createTheme, deleteLibraryColor, documentTitle, firstImageIn, noIndexField, publishThemeChild, resolveThemeIdentity, rewriteColorToken, sanitizeSvg, seedTheme, seoPlugin, themeColorKeys, titleTemplate, truncateAtWord };
|
|
234
|
+
export { BRAND_ASSETS_MIME_TYPES, BRAND_ASSETS_SLUG, type CreateBrandAssetsOptions, type CreateThemeOptions, DESCRIPTION_LENGTH, type EditableTheme, LOOK_FIELD, type LookFieldMode, type LookFieldOptions, type LookOption, type MediaId, PAGE_EDITOR_SYSTEM_KEYS, type PageEditorSystemKey, type ResolvedThemeIdentity, SHARE_IMAGE_SIZE, SYSTEM_COLOR_KEYS, type SeoDoc, type SeoImageDoc, type SeoImageSize, type SeoImageValue, type SeoMeta, type SeoPluginOptions, type SystemColorKey, THEME_APPEARANCE_FIELD, THEME_APPEARANCE_SLUG, THEME_COLORS_SLUG, THEME_COLOR_FIELD, THEME_COLOR_SCALE_FIELD, THEME_CONTRAST_REPORT, THEME_DOCUMENT_CONTROLS, THEME_FONT_FIELD, THEME_GREY_SCALE_FIELD, THEME_IDENTITY_FALLBACK, THEME_IDENTITY_SLUG, THEME_LIBRARY_FIELD, THEME_PAIRING_FIELD, THEME_PREVIEW_BREAKPOINTS, THEME_PUBLISH_FIELD, THEME_SAVE_BUTTON, THEME_SECTION_HEADING, THEME_SLUG, THEME_TYPOGRAPHY_SLUG, type ThemeChild, type ThemeColorDoc, type ThemeDoc, type ThemeIdentityFallback, type ThemeLibraryColorDoc, type ThemeUploadDoc, colorTokenField, createBrandAssets, createTheme, deleteLibraryColor, documentTitle, firstImageIn, lookField, noIndexField, pageEditorLooks, pageEditorTokens, persistThemeChild, publishThemeChild, resolveThemeIdentity, rewriteColorToken, sanitizeSvg, seedTheme, seoPlugin, themeColorKeys, themeLibraryFromDoc, titleTemplate, truncateAtWord };
|
|
211
235
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/seo/plugin.ts","../src/seo/fields.ts","../src/seo/share-image.ts","../src/seo/text.ts","../src/theme/global.ts","../src/brand-assets/collection.ts","../src/brand-assets/sanitize.ts","../src/theme/seed.ts","../src/theme/preview.ts","../src/theme/publish.ts","../src/theme/fields.ts"],"mappings":";;;;;;;;;;AAoBA;;UAAiB,MAAA;EACf,KAAA;AAAA;AAAA,UAGe,gBAAA,cAA8B,MAAA,GAAS,MAAA;EAAvB;EAE/B,QAAA;EAF6C;;;;;;EAS7C,MAAA,GAAS,GAAA,EAAK,IAAA;EAiBM;;;;;EAXpB,YAAA,IAAgB,GAAA,EAAK,IAAA;EAbrB;;;;;;EAoBA,QAAA,IAAY,GAAA,EAAK,IAAA,KAAS,OAAA;EAA1B;EAEA,WAAA,GAAc,cAAA;EAFF;EAIZ,iBAAA,GAAoB,oBAAA;AAAA;;;;;;AAetB;;;;;;;iBAAgB,SAAA,cAAuB,MAAA,GAAS,MAAA,CAAA,CAAA;EAC9C,QAAA;EACA,MAAA;EACA,YAAA;EACA,QAAA;EACA,WAAA;EACA;AAAA,GACC,gBAAA,CAAiB,IAAA,IAAQ,MAAA;;;;;;;iBA6BZ,YAAA,CACd,MAAA,WACA,KAAA,YACC,OAAA;;;;;;;;cCjGU,YAAA,EAAc,aAAA;;;;;;;;;ADa3B;;cEVa,gBAAA;;;;;;;;;cCTA,kBAAA;;;;;AHmBb;;iBGXgB,cAAA,CAAe,IAAA,UAAc,GAAA;;;;;;;AHW7C
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/seo/plugin.ts","../src/seo/fields.ts","../src/seo/share-image.ts","../src/seo/text.ts","../src/theme/global.ts","../src/brand-assets/collection.ts","../src/brand-assets/sanitize.ts","../src/theme/seed.ts","../src/theme/preview.ts","../src/theme/publish.ts","../src/theme/fields.ts"],"mappings":";;;;;;;;;;AAoBA;;UAAiB,MAAA;EACf,KAAA;AAAA;AAAA,UAGe,gBAAA,cAA8B,MAAA,GAAS,MAAA;EAAvB;EAE/B,QAAA;EAF6C;;;;;;EAS7C,MAAA,GAAS,GAAA,EAAK,IAAA;EAiBM;;;;;EAXpB,YAAA,IAAgB,GAAA,EAAK,IAAA;EAbrB;;;;;;EAoBA,QAAA,IAAY,GAAA,EAAK,IAAA,KAAS,OAAA;EAA1B;EAEA,WAAA,GAAc,cAAA;EAFF;EAIZ,iBAAA,GAAoB,oBAAA;AAAA;;;;;;AAetB;;;;;;;iBAAgB,SAAA,cAAuB,MAAA,GAAS,MAAA,CAAA,CAAA;EAC9C,QAAA;EACA,MAAA;EACA,YAAA;EAC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