payload-canvas 0.6.4 → 0.6.6

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.
@@ -1,320 +1,320 @@
1
- // Shared form controls: `Select.tsx` and `Slider.tsx`. Payload CSS variables only, no Tailwind.
2
- // The editor variables (`--be-*`) have fallbacks, so the controls also look right outside the
3
- // editor (the theme global's fields) and in a list rendered in `document.body`.
4
-
5
- @layer payload-default {
6
- .builder-select,
7
- .builder-select__popup,
8
- .builder-slider {
9
- --bc-accent: var(--be-accent, var(--theme-success-500));
10
- --bc-border: var(--be-border, var(--theme-elevation-150));
11
- --bc-muted: var(--be-muted, var(--theme-elevation-600));
12
- --bc-subtle: var(--be-subtle, var(--theme-elevation-400));
13
- --bc-hover: var(--be-hover, var(--theme-elevation-100));
14
- --bc-radius: var(--style-radius-s, 4px);
15
- --bc-ease: var(--be-ease, cubic-bezier(0.2, 0.8, 0.2, 1));
16
- }
17
-
18
- // Select trigger ------------------------------------------------------------------------------
19
-
20
- .builder-select {
21
- --bc-h: calc(var(--base, 20px) * 2);
22
-
23
- display: inline-flex;
24
- align-items: center;
25
- gap: 4px;
26
- box-sizing: border-box;
27
- width: 100%;
28
- min-width: 0;
29
- height: var(--bc-h);
30
- margin: 0;
31
- padding: 0 8px 0 calc(var(--base, 20px) * 0.5);
32
- border: 1px solid var(--bc-border);
33
- border-radius: var(--bc-radius);
34
- background: var(--theme-input-bg, var(--theme-elevation-0));
35
- color: var(--theme-text);
36
- font: inherit;
37
- font-size: var(--be-text-m);
38
- line-height: 1;
39
- text-align: left;
40
- cursor: pointer;
41
- user-select: none;
42
- transition:
43
- border-color 120ms ease,
44
- box-shadow 120ms ease;
45
-
46
- &:hover {
47
- border-color: var(--theme-elevation-250);
48
- }
49
-
50
- &[data-popup-open] .builder-select__icon,
51
- &:hover .builder-select__icon {
52
- color: var(--theme-text);
53
- }
54
-
55
- &[data-disabled] {
56
- background: var(--theme-elevation-50);
57
- color: var(--theme-elevation-600);
58
- cursor: not-allowed;
59
-
60
- &:hover {
61
- border-color: var(--bc-border);
62
- }
63
- }
64
-
65
- // Nothing chosen: the placeholder or the inherited value, dimmed.
66
- &[data-placeholder] .builder-select__value {
67
- color: var(--bc-subtle);
68
- }
69
- }
70
-
71
- // The editor's general focus ring is an outline; a select shows Payload's input ring instead.
72
- .builder-select:focus-visible,
73
- .builder-select[data-popup-open],
74
- .builder-editor .builder-select:focus-visible {
75
- border-color: var(--bc-accent);
76
- outline: 0;
77
- box-shadow: 0 0 0 1px var(--bc-accent);
78
- }
79
-
80
- .builder-select--compact {
81
- --bc-h: var(--bs-h, 26px);
82
-
83
- padding: 0 4px 0 6px;
84
- font-size: var(--be-text-m);
85
- }
86
-
87
- .builder-select__value {
88
- display: flex;
89
- flex: 1;
90
- align-items: center;
91
- gap: 6px;
92
- min-width: 0;
93
- overflow: hidden;
94
- text-overflow: ellipsis;
95
- white-space: nowrap;
96
- }
97
-
98
- .builder-select__icon {
99
- display: grid;
100
- flex: none;
101
- place-items: center;
102
- color: var(--bc-muted);
103
- transition: color 120ms ease;
104
- }
105
-
106
- // A trigger with its own content (an icon): centered, no chevron.
107
- .builder-select--custom {
108
- justify-content: center;
109
- padding: 0;
110
- color: var(--bc-muted);
111
- }
112
-
113
- // Select list ---------------------------------------------------------------------------------
114
-
115
- // Above Payload's drawers and modals: the list may open from inside one.
116
- .builder-select__positioner {
117
- z-index: 10000;
118
- outline: 0;
119
- }
120
-
121
- .builder-select__popup {
122
- display: flex;
123
- flex-direction: column;
124
- box-sizing: border-box;
125
- min-width: max(var(--anchor-width, 0px), 160px);
126
- max-width: min(320px, var(--available-width, 320px));
127
- max-height: min(360px, var(--available-height, 360px));
128
- padding: 4px;
129
- border: 1px solid var(--bc-border);
130
- border-radius: var(--be-radius-m, var(--style-radius-m, 6px));
131
- background: var(--theme-bg);
132
- color: var(--theme-text);
133
- font-family: var(--font-body);
134
- font-size: var(--be-text-m);
135
- line-height: 1.3;
136
- box-shadow: var(--be-shadow);
137
- outline: 0;
138
- transform-origin: var(--transform-origin);
139
-
140
- @media (prefers-reduced-motion: no-preference) {
141
- transition:
142
- opacity 100ms ease,
143
- transform 100ms var(--bc-ease);
144
- }
145
-
146
- &[data-starting-style],
147
- &[data-ending-style] {
148
- opacity: 0;
149
- transform: scale(0.98) translateY(-2px);
150
- }
151
- }
152
-
153
- .builder-select__list {
154
- min-height: 0;
155
- overflow-y: auto;
156
- overscroll-behavior: contain;
157
- scroll-padding-block: 4px;
158
- outline: 0;
159
- }
160
-
161
- .builder-select__item {
162
- display: grid;
163
- grid-template-columns: 12px minmax(0, 1fr) auto;
164
- align-items: center;
165
- gap: 6px;
166
- box-sizing: border-box;
167
- min-height: 28px;
168
- padding: 5px 8px 5px 6px;
169
- border-radius: var(--bc-radius);
170
- color: var(--theme-text);
171
- cursor: default;
172
- outline: 0;
173
- user-select: none;
174
- scroll-margin-block: 4px;
175
-
176
- &[data-highlighted] {
177
- background: var(--bc-hover);
178
- }
179
-
180
- &[data-selected] {
181
- font-weight: var(--be-weight-medium);
182
- }
183
-
184
- &[data-disabled] {
185
- opacity: 0.4;
186
- }
187
- }
188
-
189
- // Long labels wrap in the list, so the full text is always readable there.
190
- .builder-select__item-text {
191
- min-width: 0;
192
- overflow-wrap: anywhere;
193
- }
194
-
195
- .builder-select__check {
196
- display: grid;
197
- place-items: center;
198
- width: 12px;
199
- color: var(--bc-accent);
200
- }
201
-
202
- .builder-select__popup--compact {
203
- font-size: var(--be-text-m);
204
-
205
- .builder-select__item {
206
- min-height: 26px;
207
- padding-block: 4px;
208
- }
209
- }
210
-
211
- .builder-select__group-label {
212
- padding: 6px 8px 2px 24px;
213
- color: var(--bc-muted);
214
- font-size: var(--be-text-s);
215
- font-weight: var(--be-weight-medium);
216
- }
217
-
218
- .builder-select__separator {
219
- height: 1px;
220
- margin: 4px 0;
221
- border: 0;
222
- background: var(--be-border-soft, var(--theme-elevation-100));
223
- }
224
-
225
- // The highlight shows the keyboard position; no focus ring inside the list.
226
- .builder-editor .builder-select__popup:focus-visible,
227
- .builder-editor .builder-select__item:focus-visible {
228
- outline: 0;
229
- }
230
-
231
- // Slider --------------------------------------------------------------------------------------
232
-
233
- .builder-slider {
234
- flex: 1;
235
- min-width: 0;
236
- touch-action: none;
237
-
238
- &[data-disabled] {
239
- opacity: 0.45;
240
- }
241
- }
242
-
243
- // 20 px tall: the pointer target. The track inside is 3 px.
244
- .builder-slider__control {
245
- display: flex;
246
- align-items: center;
247
- height: 20px;
248
- cursor: pointer;
249
-
250
- [data-disabled] > & {
251
- cursor: not-allowed;
252
- }
253
- }
254
-
255
- .builder-slider__track {
256
- position: relative;
257
- width: 100%;
258
- height: 3px;
259
- border-radius: 999px;
260
- background: var(--theme-elevation-150);
261
- }
262
-
263
- .builder-slider__indicator {
264
- height: 100%;
265
- border-radius: inherit;
266
- background: var(--bc-accent);
267
- }
268
-
269
- .builder-slider__thumb {
270
- box-sizing: border-box;
271
- width: 12px;
272
- height: 12px;
273
- border-radius: 50%;
274
- // The page color with a visible ring, so a grey (unset) slider never reads as disabled on white.
275
- background: var(--theme-elevation-0);
276
- box-shadow:
277
- 0 0 0 1px var(--theme-elevation-400),
278
- 0 1px 3px rgb(0 0 0 / 0.22);
279
- transition:
280
- box-shadow 120ms ease,
281
- scale 120ms var(--bc-ease);
282
-
283
- // A larger invisible hit area around the 12 px thumb.
284
- &::before {
285
- content: '';
286
- position: absolute;
287
- inset: -6px;
288
- border-radius: 50%;
289
- }
290
-
291
- .builder-slider__control:hover &,
292
- &[data-dragging] {
293
- box-shadow:
294
- 0 0 0 1px var(--theme-elevation-400),
295
- 0 1px 3px rgb(0 0 0 / 0.22),
296
- 0 0 0 4px color-mix(in srgb, var(--bc-accent) 18%, transparent);
297
- }
298
-
299
- &[data-dragging] {
300
- scale: 1.12;
301
- }
302
-
303
- // Focus sits on the hidden range input inside the thumb.
304
- &:has(:focus-visible) {
305
- box-shadow:
306
- 0 0 0 1px var(--theme-elevation-400),
307
- 0 1px 3px rgb(0 0 0 / 0.22),
308
- 0 0 0 3px color-mix(in srgb, var(--bc-accent) 45%, transparent);
309
- }
310
-
311
- [data-disabled] & {
312
- box-shadow: 0 0 0 1px rgb(0 0 0 / 0.14);
313
- }
314
- }
315
-
316
- // The value is a default or inherited: a grey fill, so it reads as "not set here".
317
- .builder-slider[data-muted] .builder-slider__indicator {
318
- background: var(--theme-elevation-300);
319
- }
320
- }
1
+ // Shared form controls: `Select.tsx` and `Slider.tsx`. Payload CSS variables only, no Tailwind.
2
+ // The editor variables (`--be-*`) have fallbacks, so the controls also look right outside the
3
+ // editor (the theme global's fields) and in a list rendered in `document.body`.
4
+
5
+ @layer payload-default {
6
+ .builder-select,
7
+ .builder-select__popup,
8
+ .builder-slider {
9
+ --bc-accent: var(--be-accent, var(--theme-success-500));
10
+ --bc-border: var(--be-border, var(--theme-elevation-150));
11
+ --bc-muted: var(--be-muted, var(--theme-elevation-600));
12
+ --bc-subtle: var(--be-subtle, var(--theme-elevation-400));
13
+ --bc-hover: var(--be-hover, var(--theme-elevation-100));
14
+ --bc-radius: var(--style-radius-s, 4px);
15
+ --bc-ease: var(--be-ease, cubic-bezier(0.2, 0.8, 0.2, 1));
16
+ }
17
+
18
+ // Select trigger ------------------------------------------------------------------------------
19
+
20
+ .builder-select {
21
+ --bc-h: calc(var(--base, 20px) * 2);
22
+
23
+ display: inline-flex;
24
+ align-items: center;
25
+ gap: 4px;
26
+ box-sizing: border-box;
27
+ width: 100%;
28
+ min-width: 0;
29
+ height: var(--bc-h);
30
+ margin: 0;
31
+ padding: 0 8px 0 calc(var(--base, 20px) * 0.5);
32
+ border: 1px solid var(--bc-border);
33
+ border-radius: var(--bc-radius);
34
+ background: var(--theme-input-bg, var(--theme-elevation-0));
35
+ color: var(--theme-text);
36
+ font: inherit;
37
+ font-size: var(--be-text-m);
38
+ line-height: 1;
39
+ text-align: left;
40
+ cursor: pointer;
41
+ user-select: none;
42
+ transition:
43
+ border-color 120ms ease,
44
+ box-shadow 120ms ease;
45
+
46
+ &:hover {
47
+ border-color: var(--theme-elevation-250);
48
+ }
49
+
50
+ &[data-popup-open] .builder-select__icon,
51
+ &:hover .builder-select__icon {
52
+ color: var(--theme-text);
53
+ }
54
+
55
+ &[data-disabled] {
56
+ background: var(--theme-elevation-50);
57
+ color: var(--theme-elevation-600);
58
+ cursor: not-allowed;
59
+
60
+ &:hover {
61
+ border-color: var(--bc-border);
62
+ }
63
+ }
64
+
65
+ // Nothing chosen: the placeholder or the inherited value, dimmed.
66
+ &[data-placeholder] .builder-select__value {
67
+ color: var(--bc-subtle);
68
+ }
69
+ }
70
+
71
+ // The editor's general focus ring is an outline; a select shows Payload's input ring instead.
72
+ .builder-select:focus-visible,
73
+ .builder-select[data-popup-open],
74
+ .builder-editor .builder-select:focus-visible {
75
+ border-color: var(--bc-accent);
76
+ outline: 0;
77
+ box-shadow: 0 0 0 1px var(--bc-accent);
78
+ }
79
+
80
+ .builder-select--compact {
81
+ --bc-h: var(--bs-h, 26px);
82
+
83
+ padding: 0 4px 0 6px;
84
+ font-size: var(--be-text-m);
85
+ }
86
+
87
+ .builder-select__value {
88
+ display: flex;
89
+ flex: 1;
90
+ align-items: center;
91
+ gap: 6px;
92
+ min-width: 0;
93
+ overflow: hidden;
94
+ text-overflow: ellipsis;
95
+ white-space: nowrap;
96
+ }
97
+
98
+ .builder-select__icon {
99
+ display: grid;
100
+ flex: none;
101
+ place-items: center;
102
+ color: var(--bc-muted);
103
+ transition: color 120ms ease;
104
+ }
105
+
106
+ // A trigger with its own content (an icon): centered, no chevron.
107
+ .builder-select--custom {
108
+ justify-content: center;
109
+ padding: 0;
110
+ color: var(--bc-muted);
111
+ }
112
+
113
+ // Select list ---------------------------------------------------------------------------------
114
+
115
+ // Above Payload's drawers and modals: the list may open from inside one.
116
+ .builder-select__positioner {
117
+ z-index: 10000;
118
+ outline: 0;
119
+ }
120
+
121
+ .builder-select__popup {
122
+ display: flex;
123
+ flex-direction: column;
124
+ box-sizing: border-box;
125
+ min-width: max(var(--anchor-width, 0px), 160px);
126
+ max-width: min(320px, var(--available-width, 320px));
127
+ max-height: min(360px, var(--available-height, 360px));
128
+ padding: 4px;
129
+ border: 1px solid var(--bc-border);
130
+ border-radius: var(--be-radius-m, var(--style-radius-m, 6px));
131
+ background: var(--theme-bg);
132
+ color: var(--theme-text);
133
+ font-family: var(--font-body);
134
+ font-size: var(--be-text-m);
135
+ line-height: 1.3;
136
+ box-shadow: var(--be-shadow);
137
+ outline: 0;
138
+ transform-origin: var(--transform-origin);
139
+
140
+ @media (prefers-reduced-motion: no-preference) {
141
+ transition:
142
+ opacity 100ms ease,
143
+ transform 100ms var(--bc-ease);
144
+ }
145
+
146
+ &[data-starting-style],
147
+ &[data-ending-style] {
148
+ opacity: 0;
149
+ transform: scale(0.98) translateY(-2px);
150
+ }
151
+ }
152
+
153
+ .builder-select__list {
154
+ min-height: 0;
155
+ overflow-y: auto;
156
+ overscroll-behavior: contain;
157
+ scroll-padding-block: 4px;
158
+ outline: 0;
159
+ }
160
+
161
+ .builder-select__item {
162
+ display: grid;
163
+ grid-template-columns: 12px minmax(0, 1fr) auto;
164
+ align-items: center;
165
+ gap: 6px;
166
+ box-sizing: border-box;
167
+ min-height: 28px;
168
+ padding: 5px 8px 5px 6px;
169
+ border-radius: var(--bc-radius);
170
+ color: var(--theme-text);
171
+ cursor: default;
172
+ outline: 0;
173
+ user-select: none;
174
+ scroll-margin-block: 4px;
175
+
176
+ &[data-highlighted] {
177
+ background: var(--bc-hover);
178
+ }
179
+
180
+ &[data-selected] {
181
+ font-weight: var(--be-weight-medium);
182
+ }
183
+
184
+ &[data-disabled] {
185
+ opacity: 0.4;
186
+ }
187
+ }
188
+
189
+ // Long labels wrap in the list, so the full text is always readable there.
190
+ .builder-select__item-text {
191
+ min-width: 0;
192
+ overflow-wrap: anywhere;
193
+ }
194
+
195
+ .builder-select__check {
196
+ display: grid;
197
+ place-items: center;
198
+ width: 12px;
199
+ color: var(--bc-accent);
200
+ }
201
+
202
+ .builder-select__popup--compact {
203
+ font-size: var(--be-text-m);
204
+
205
+ .builder-select__item {
206
+ min-height: 26px;
207
+ padding-block: 4px;
208
+ }
209
+ }
210
+
211
+ .builder-select__group-label {
212
+ padding: 6px 8px 2px 24px;
213
+ color: var(--bc-muted);
214
+ font-size: var(--be-text-s);
215
+ font-weight: var(--be-weight-medium);
216
+ }
217
+
218
+ .builder-select__separator {
219
+ height: 1px;
220
+ margin: 4px 0;
221
+ border: 0;
222
+ background: var(--be-border-soft, var(--theme-elevation-100));
223
+ }
224
+
225
+ // The highlight shows the keyboard position; no focus ring inside the list.
226
+ .builder-editor .builder-select__popup:focus-visible,
227
+ .builder-editor .builder-select__item:focus-visible {
228
+ outline: 0;
229
+ }
230
+
231
+ // Slider --------------------------------------------------------------------------------------
232
+
233
+ .builder-slider {
234
+ flex: 1;
235
+ min-width: 0;
236
+ touch-action: none;
237
+
238
+ &[data-disabled] {
239
+ opacity: 0.45;
240
+ }
241
+ }
242
+
243
+ // 20 px tall: the pointer target. The track inside is 3 px.
244
+ .builder-slider__control {
245
+ display: flex;
246
+ align-items: center;
247
+ height: 20px;
248
+ cursor: pointer;
249
+
250
+ [data-disabled] > & {
251
+ cursor: not-allowed;
252
+ }
253
+ }
254
+
255
+ .builder-slider__track {
256
+ position: relative;
257
+ width: 100%;
258
+ height: 3px;
259
+ border-radius: 999px;
260
+ background: var(--theme-elevation-150);
261
+ }
262
+
263
+ .builder-slider__indicator {
264
+ height: 100%;
265
+ border-radius: inherit;
266
+ background: var(--bc-accent);
267
+ }
268
+
269
+ .builder-slider__thumb {
270
+ box-sizing: border-box;
271
+ width: 12px;
272
+ height: 12px;
273
+ border-radius: 50%;
274
+ // The page color with a visible ring, so a grey (unset) slider never reads as disabled on white.
275
+ background: var(--theme-elevation-0);
276
+ box-shadow:
277
+ 0 0 0 1px var(--theme-elevation-400),
278
+ 0 1px 3px rgb(0 0 0 / 0.22);
279
+ transition:
280
+ box-shadow 120ms ease,
281
+ scale 120ms var(--bc-ease);
282
+
283
+ // A larger invisible hit area around the 12 px thumb.
284
+ &::before {
285
+ content: '';
286
+ position: absolute;
287
+ inset: -6px;
288
+ border-radius: 50%;
289
+ }
290
+
291
+ .builder-slider__control:hover &,
292
+ &[data-dragging] {
293
+ box-shadow:
294
+ 0 0 0 1px var(--theme-elevation-400),
295
+ 0 1px 3px rgb(0 0 0 / 0.22),
296
+ 0 0 0 4px color-mix(in srgb, var(--bc-accent) 18%, transparent);
297
+ }
298
+
299
+ &[data-dragging] {
300
+ scale: 1.12;
301
+ }
302
+
303
+ // Focus sits on the hidden range input inside the thumb.
304
+ &:has(:focus-visible) {
305
+ box-shadow:
306
+ 0 0 0 1px var(--theme-elevation-400),
307
+ 0 1px 3px rgb(0 0 0 / 0.22),
308
+ 0 0 0 3px color-mix(in srgb, var(--bc-accent) 45%, transparent);
309
+ }
310
+
311
+ [data-disabled] & {
312
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.14);
313
+ }
314
+ }
315
+
316
+ // The value is a default or inherited: a grey fill, so it reads as "not set here".
317
+ .builder-slider[data-muted] .builder-slider__indicator {
318
+ background: var(--theme-elevation-300);
319
+ }
320
+ }
@@ -1,6 +1,7 @@
1
1
  // The classes collection: one document per editable class, with drafts and versions. Server-only
2
2
  // (the revalidation imports next/cache).
3
3
  import { revalidatePath } from 'next/cache';
4
+ import { clearAgainAfterResponse } from '../core/clearAgain.js';
4
5
  import { APIError, } from 'payload';
5
6
  import { isTailwindUtility } from '../css/index.js';
6
7
  import { classesConfigOf } from './config.js';
@@ -72,6 +73,7 @@ function revalidate(req) {
72
73
  return;
73
74
  try {
74
75
  revalidatePath('/', 'layout');
76
+ clearAgainAfterResponse(() => revalidatePath('/', 'layout'));
75
77
  }
76
78
  catch (error) {
77
79
  req.payload.logger.debug(`[websiteBuilder] Classes revalidation skipped: ${error instanceof Error ? error.message : String(error)}`);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Runs `clear` again a few seconds after the response. A page render that started before the save
3
+ * stores what it read before the save, and Next keeps it as fresh until the next save. The second
4
+ * run marks that page stale too. Outside a Next request `after` throws; callers catch and log it.
5
+ */
6
+ export declare function clearAgainAfterResponse(clear: () => void): void;
@@ -0,0 +1,14 @@
1
+ import { after } from 'next/server';
2
+ /** Long enough for a page render that started before a save to finish. */
3
+ const SETTLE_MS = 5000;
4
+ /**
5
+ * Runs `clear` again a few seconds after the response. A page render that started before the save
6
+ * stores what it read before the save, and Next keeps it as fresh until the next save. The second
7
+ * run marks that page stale too. Outside a Next request `after` throws; callers catch and log it.
8
+ */
9
+ export function clearAgainAfterResponse(clear) {
10
+ after(async () => {
11
+ await new Promise((resolve) => setTimeout(resolve, SETTLE_MS));
12
+ clear();
13
+ });
14
+ }