camox 0.66.0 → 0.67.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.
@@ -2,8 +2,8 @@ import { useViewLocale } from "../../../lib/view-locale-context.js";
2
2
  import { useProjectUuid } from "../../../lib/auth.js";
3
3
  import { reads, useReadQuery, useStudioCache } from "../../../lib/studio-reads.js";
4
4
  import { localeMutations } from "../../../lib/queries.js";
5
- import { ContentSidebarGroup } from "./ContentSidebarGroup.js";
6
5
  import { localeLabel } from "../../studio/localeOptions.js";
6
+ import { ContentSidebarGroup } from "./ContentSidebarGroup.js";
7
7
  import { c } from "react/compiler-runtime";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { useMutation } from "@tanstack/react-query";
@@ -0,0 +1,141 @@
1
+ import { useViewLocale } from "../../lib/view-locale-context.js";
2
+ import { usePageBlocks } from "../../lib/normalized-data.js";
3
+ import { buildLayoutContext } from "../../core/layoutContext.js";
4
+ import { SharedLayoutContent } from "./SharedLayoutContent.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { jsx } from "react/jsx-runtime";
7
+
8
+ //#region src/features/page/UnplacedLayoutContent.tsx
9
+ const EMPTY_PAGE = { blockIds: [] };
10
+ /**
11
+ * How tall the placeholder stands: short enough to leave the footer on the first screen, which
12
+ * shows whether it rises up it, or taller than any screen, as a long page is.
13
+ */
14
+ const PLACEHOLDER_HEIGHTS = {
15
+ short: "16rem",
16
+ tall: "300vh"
17
+ };
18
+ /** A grey that reads on light and dark Themes alike. */
19
+ const HATCH = "rgba(128, 128, 128, 0.35)";
20
+ /**
21
+ * Where a page's content goes, as the look document's Layout Definition mode shows it: a labelled,
22
+ * hatched area, styled inline, since the site's stylesheet knows nothing of it.
23
+ */
24
+ function PageContentPlaceholder(t0) {
25
+ const $ = c(6);
26
+ const { height } = t0;
27
+ const t1 = PLACEHOLDER_HEIGHTS[height];
28
+ let t2;
29
+ if ($[0] !== t1) {
30
+ t2 = {
31
+ minHeight: t1,
32
+ display: "flex",
33
+ alignItems: "flex-start",
34
+ justifyContent: "center",
35
+ padding: "2rem",
36
+ border: `2px dashed ${HATCH}`,
37
+ backgroundImage: `repeating-linear-gradient(45deg, ${HATCH} 0 2px, transparent 2px 14px)`,
38
+ font: "600 14px/1.4 system-ui, sans-serif",
39
+ color: "rgb(128, 128, 128)"
40
+ };
41
+ $[0] = t1;
42
+ $[1] = t2;
43
+ } else t2 = $[1];
44
+ const style = t2;
45
+ let t3;
46
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47
+ t3 = /* @__PURE__ */ jsx("span", { children: "Page content" });
48
+ $[2] = t3;
49
+ } else t3 = $[2];
50
+ let t4;
51
+ if ($[3] !== height || $[4] !== style) {
52
+ t4 = /* @__PURE__ */ jsx("div", {
53
+ "data-camox-look-placeholder": height,
54
+ style,
55
+ children: t3
56
+ });
57
+ $[3] = height;
58
+ $[4] = style;
59
+ $[5] = t4;
60
+ } else t4 = $[5];
61
+ return t4;
62
+ }
63
+ /**
64
+ * A curated Layout around no page, alone, as the look document's Layout Definition mode shows it
65
+ * (ADR 0032): its blocks, read like a Layout's, around a placeholder for a page's content.
66
+ */
67
+ function UnplacedLayoutContent(t0) {
68
+ const $ = c(21);
69
+ const { camoxApp, lookLayout } = t0;
70
+ let t1;
71
+ if ($[0] !== lookLayout.layout) {
72
+ t1 = {
73
+ page: EMPTY_PAGE,
74
+ layout: lookLayout.layout
75
+ };
76
+ $[0] = lookLayout.layout;
77
+ $[1] = t1;
78
+ } else t1 = $[1];
79
+ const { beforeBlocks, afterBlocks, layoutFiles, layoutItems } = usePageBlocks(t1);
80
+ const { locale } = useViewLocale();
81
+ let t2;
82
+ if ($[2] !== camoxApp || $[3] !== lookLayout.layoutId) {
83
+ t2 = camoxApp.getLayoutById(lookLayout.layoutId);
84
+ $[2] = camoxApp;
85
+ $[3] = lookLayout.layoutId;
86
+ $[4] = t2;
87
+ } else t2 = $[4];
88
+ const layout = t2;
89
+ if (!layout) throw new Error(`Unknown layout: ${lookLayout.layoutId}`);
90
+ let t3;
91
+ if ($[5] !== locale.tag || $[6] !== lookLayout.path || $[7] !== lookLayout.projectName) {
92
+ t3 = buildLayoutContext({
93
+ kind: "curated",
94
+ title: ""
95
+ }, {
96
+ path: lookLayout.path,
97
+ locale: locale.tag,
98
+ projectName: lookLayout.projectName
99
+ });
100
+ $[5] = locale.tag;
101
+ $[6] = lookLayout.path;
102
+ $[7] = lookLayout.projectName;
103
+ $[8] = t3;
104
+ } else t3 = $[8];
105
+ const context = t3;
106
+ let t4;
107
+ if ($[9] !== afterBlocks || $[10] !== beforeBlocks) {
108
+ t4 = [...beforeBlocks, ...afterBlocks];
109
+ $[9] = afterBlocks;
110
+ $[10] = beforeBlocks;
111
+ $[11] = t4;
112
+ } else t4 = $[11];
113
+ let t5;
114
+ if ($[12] !== lookLayout.placeholder) {
115
+ t5 = /* @__PURE__ */ jsx(PageContentPlaceholder, { height: lookLayout.placeholder });
116
+ $[12] = lookLayout.placeholder;
117
+ $[13] = t5;
118
+ } else t5 = $[13];
119
+ let t6;
120
+ if ($[14] !== context || $[15] !== layout || $[16] !== layoutFiles || $[17] !== layoutItems || $[18] !== t4 || $[19] !== t5) {
121
+ t6 = /* @__PURE__ */ jsx(SharedLayoutContent, {
122
+ layout,
123
+ context,
124
+ blocks: t4,
125
+ files: layoutFiles,
126
+ repeatableItems: layoutItems,
127
+ children: t5
128
+ });
129
+ $[14] = context;
130
+ $[15] = layout;
131
+ $[16] = layoutFiles;
132
+ $[17] = layoutItems;
133
+ $[18] = t4;
134
+ $[19] = t5;
135
+ $[20] = t6;
136
+ } else t6 = $[20];
137
+ return t6;
138
+ }
139
+
140
+ //#endregion
141
+ export { UnplacedLayoutContent };
@@ -45,8 +45,8 @@ const getSchemaFieldsInOrder = (schema) => {
45
45
  });
46
46
  };
47
47
  const ItemFieldsEditor = (t0) => {
48
- const $ = c(58);
49
- const { selectedFieldName, schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap, references, placement, fieldIdPrefix } = t0;
48
+ const $ = c(59);
49
+ const { selectedFieldName, schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap, references, placement, fieldIdPrefix, fieldHint } = t0;
50
50
  const owner = React.useContext(PreviewEditingOwnerContext);
51
51
  let t1;
52
52
  if ($[0] !== schema || $[1] !== selectedFieldName) {
@@ -146,7 +146,7 @@ const ItemFieldsEditor = (t0) => {
146
146
  React.useEffect(t8, t9);
147
147
  let t10;
148
148
  let t11;
149
- if ($[25] !== blockId || $[26] !== data || $[27] !== fields || $[28] !== filesMap || $[29] !== form || $[30] !== getFieldElementId || $[31] !== getFieldId || $[32] !== itemId || $[33] !== itemsMap || $[34] !== onFieldChange || $[35] !== owner || $[36] !== placement || $[37] !== postToIframe || $[38] !== references || $[39] !== schema || $[40] !== selectedFieldName) {
149
+ if ($[25] !== blockId || $[26] !== data || $[27] !== fieldHint || $[28] !== fields || $[29] !== filesMap || $[30] !== form || $[31] !== getFieldElementId || $[32] !== getFieldId || $[33] !== itemId || $[34] !== itemsMap || $[35] !== onFieldChange || $[36] !== owner || $[37] !== placement || $[38] !== postToIframe || $[39] !== references || $[40] !== schema || $[41] !== selectedFieldName) {
150
150
  const handleScalarChange = (fieldName_2, value, fieldApi) => {
151
151
  fieldApi.handleChange(value);
152
152
  if (timerRef.current) clearTimeout(timerRef.current);
@@ -158,7 +158,7 @@ const ItemFieldsEditor = (t0) => {
158
158
  }, 500);
159
159
  };
160
160
  let t12;
161
- if ($[43] !== blockId || $[44] !== itemId || $[45] !== owner || $[46] !== placement) {
161
+ if ($[44] !== blockId || $[45] !== itemId || $[46] !== owner || $[47] !== placement) {
162
162
  t12 = (fieldName_3, fieldType) => {
163
163
  if (owner === null) return;
164
164
  if (placement) {
@@ -190,12 +190,12 @@ const ItemFieldsEditor = (t0) => {
190
190
  fieldType
191
191
  });
192
192
  };
193
- $[43] = blockId;
194
- $[44] = itemId;
195
- $[45] = owner;
196
- $[46] = placement;
197
- $[47] = t12;
198
- } else t12 = $[47];
193
+ $[44] = blockId;
194
+ $[45] = itemId;
195
+ $[46] = owner;
196
+ $[47] = placement;
197
+ $[48] = t12;
198
+ } else t12 = $[48];
199
199
  const selectField = t12;
200
200
  const handleFieldFocus = (fieldName_4, fieldType_0) => {
201
201
  if (owner === null) return;
@@ -216,7 +216,7 @@ const ItemFieldsEditor = (t0) => {
216
216
  });
217
217
  };
218
218
  let t13;
219
- if ($[48] !== blockId || $[49] !== itemId || $[50] !== placement) {
219
+ if ($[49] !== blockId || $[50] !== itemId || $[51] !== placement) {
220
220
  t13 = (fieldName_6, recordId) => placement ? {
221
221
  ...placement,
222
222
  nested: {
@@ -229,15 +229,15 @@ const ItemFieldsEditor = (t0) => {
229
229
  fieldName: fieldName_6,
230
230
  recordId
231
231
  };
232
- $[48] = blockId;
233
- $[49] = itemId;
234
- $[50] = placement;
235
- $[51] = t13;
236
- } else t13 = $[51];
232
+ $[49] = blockId;
233
+ $[50] = itemId;
234
+ $[51] = placement;
235
+ $[52] = t13;
236
+ } else t13 = $[52];
237
237
  const placementOf = t13;
238
238
  const opensRecords = !placement?.nested;
239
239
  let t14;
240
- if ($[52] !== owner || $[53] !== placementOf) {
240
+ if ($[53] !== owner || $[54] !== placementOf) {
241
241
  t14 = (fieldName_7, recordId_0) => {
242
242
  if (owner === null) return;
243
243
  previewStore.send({
@@ -246,10 +246,10 @@ const ItemFieldsEditor = (t0) => {
246
246
  ...placementOf(fieldName_7, recordId_0)
247
247
  });
248
248
  };
249
- $[52] = owner;
250
- $[53] = placementOf;
251
- $[54] = t14;
252
- } else t14 = $[54];
249
+ $[53] = owner;
250
+ $[54] = placementOf;
251
+ $[55] = t14;
252
+ } else t14 = $[55];
253
253
  const openRecord = t14;
254
254
  t10 = "space-y-4 px-2 py-4";
255
255
  t11 = fields.map((field_0) => {
@@ -342,6 +342,7 @@ const ItemFieldsEditor = (t0) => {
342
342
  const preview = field_0.fieldType === "String" ? lexicalStateToPlainText(value_2 ?? "") || "Empty text" : field_0.fieldType === "Repeater" ? `${Array.isArray(value_2) ? value_2.length : 0} items` : field_0.fieldType === "Boolean" ? value_2 ? "On" : "Off" : typeof value_2 === "string" && value_2 ? value_2 : "Empty";
343
343
  return /* @__PURE__ */ jsx(DrillRow, {
344
344
  label,
345
+ hint: fieldHint?.(field_0.name),
345
346
  preview,
346
347
  Icon: field_0.fieldType === "String" ? Type : field_0.fieldType === "Repeater" ? List : field_0.fieldType === "Embed" ? Code : field_0.fieldType === "Boolean" ? ToggleLeft : ListFilter,
347
348
  onClick: () => selectField(field_0.name, field_0.fieldType),
@@ -444,6 +445,7 @@ const ItemFieldsEditor = (t0) => {
444
445
  const preview_0 = linkValue?.text || linkValue?.href || "Empty link";
445
446
  return /* @__PURE__ */ jsx(DrillRow, {
446
447
  label,
448
+ hint: fieldHint?.(field_0.name),
447
449
  preview: preview_0,
448
450
  Icon: Link2,
449
451
  onClick: () => selectField(field_0.name, "Link"),
@@ -465,6 +467,7 @@ const ItemFieldsEditor = (t0) => {
465
467
  else preview_1 = `${count} ${noun}s`;
466
468
  return /* @__PURE__ */ jsx(DrillRow, {
467
469
  label,
470
+ hint: fieldHint?.(field_0.name),
468
471
  preview: preview_1,
469
472
  Icon: isImage ? Images : FileIcon,
470
473
  onClick: () => selectField(field_0.name, isImage ? "Image" : "File"),
@@ -480,6 +483,7 @@ const ItemFieldsEditor = (t0) => {
480
483
  const preview_2 = resolveAssetValue(data[field_0.name], filesMap)?.filename || "No image";
481
484
  return /* @__PURE__ */ jsx(DrillRow, {
482
485
  label,
486
+ hint: fieldHint?.(field_0.name),
483
487
  preview: preview_2,
484
488
  Icon: ImageIcon,
485
489
  onClick: () => selectField(field_0.name, "Image"),
@@ -494,6 +498,7 @@ const ItemFieldsEditor = (t0) => {
494
498
  const preview_3 = resolveAssetValue(data[field_0.name], filesMap)?.filename || "No file";
495
499
  return /* @__PURE__ */ jsx(DrillRow, {
496
500
  label,
501
+ hint: fieldHint?.(field_0.name),
497
502
  preview: preview_3,
498
503
  Icon: FileIcon,
499
504
  onClick: () => selectField(field_0.name, "File"),
@@ -526,36 +531,37 @@ const ItemFieldsEditor = (t0) => {
526
531
  });
527
532
  $[25] = blockId;
528
533
  $[26] = data;
529
- $[27] = fields;
530
- $[28] = filesMap;
531
- $[29] = form;
532
- $[30] = getFieldElementId;
533
- $[31] = getFieldId;
534
- $[32] = itemId;
535
- $[33] = itemsMap;
536
- $[34] = onFieldChange;
537
- $[35] = owner;
538
- $[36] = placement;
539
- $[37] = postToIframe;
540
- $[38] = references;
541
- $[39] = schema;
542
- $[40] = selectedFieldName;
543
- $[41] = t10;
544
- $[42] = t11;
534
+ $[27] = fieldHint;
535
+ $[28] = fields;
536
+ $[29] = filesMap;
537
+ $[30] = form;
538
+ $[31] = getFieldElementId;
539
+ $[32] = getFieldId;
540
+ $[33] = itemId;
541
+ $[34] = itemsMap;
542
+ $[35] = onFieldChange;
543
+ $[36] = owner;
544
+ $[37] = placement;
545
+ $[38] = postToIframe;
546
+ $[39] = references;
547
+ $[40] = schema;
548
+ $[41] = selectedFieldName;
549
+ $[42] = t10;
550
+ $[43] = t11;
545
551
  } else {
546
- t10 = $[41];
547
- t11 = $[42];
552
+ t10 = $[42];
553
+ t11 = $[43];
548
554
  }
549
555
  let t12;
550
- if ($[55] !== t10 || $[56] !== t11) {
556
+ if ($[56] !== t10 || $[57] !== t11) {
551
557
  t12 = /* @__PURE__ */ jsx("form", {
552
558
  className: t10,
553
559
  children: t11
554
560
  });
555
- $[55] = t10;
556
- $[56] = t11;
557
- $[57] = t12;
558
- } else t12 = $[57];
561
+ $[56] = t10;
562
+ $[57] = t11;
563
+ $[58] = t12;
564
+ } else t12 = $[58];
559
565
  return t12;
560
566
  };
561
567
  function _temp(f) {