alinea 2.0.0-preview.2 → 2.0.0-preview.4

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.
Files changed (178) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +157 -103
  3. package/dist/adapter/next/DevRemote.js +10 -2
  4. package/dist/adapter/next/previews.js +4 -1
  5. package/dist/adapter/next/previews.spec.d.ts +1 -0
  6. package/dist/backend/Handler.js +14 -7
  7. package/dist/backend/api/BasicAuth.d.ts +1 -1
  8. package/dist/backend/api/BasicAuth.js +14 -14
  9. package/dist/backend/api/OAuth2.d.ts +3 -3
  10. package/dist/backend/api/OAuth2.js +7 -4
  11. package/dist/bundled.d.ts +159 -42
  12. package/dist/chunks/{chunk-Y7XOMJOC.js → chunk-CFNRVI3Y.js} +220 -247
  13. package/dist/chunks/chunk-D6UJHBJJ.js +183 -0
  14. package/dist/chunks/chunk-TIJTT5ZI.js +228 -0
  15. package/dist/chunks/{chunk-UVOEM4AH.js → chunk-XMOVGDFI.js} +1 -1
  16. package/dist/cli/Serve.js +1 -1
  17. package/dist/cli/bin.js +1 -1
  18. package/dist/cli/serve/LocalAuth.js +1 -1
  19. package/dist/cloud/AuthResult.d.ts +2 -0
  20. package/dist/cloud/CloudHandshake.d.ts +7 -0
  21. package/dist/cloud/CloudHandshake.js +64 -0
  22. package/dist/cloud/CloudRemote.d.ts +4 -1
  23. package/dist/cloud/CloudRemote.js +21 -3
  24. package/dist/components/Breadcrumbs.js +2 -2
  25. package/dist/components/Calendar.js +6 -6
  26. package/dist/components/Checkbox.js +3 -3
  27. package/dist/components/ComboBox.js +11 -11
  28. package/dist/components/DateField.js +3 -3
  29. package/dist/components/DatePicker.js +4 -4
  30. package/dist/components/DateRangePicker.js +6 -6
  31. package/dist/components/Disclosure.js +8 -8
  32. package/dist/components/Label.js +5 -5
  33. package/dist/components/List.js +34 -34
  34. package/dist/components/Menu.js +4 -4
  35. package/dist/components/Modal.js +3 -3
  36. package/dist/components/MultipleSelect.js +25 -25
  37. package/dist/components/NumberField.js +6 -6
  38. package/dist/components/ProgressCircle.js +2 -2
  39. package/dist/components/RadioGroup.js +2 -2
  40. package/dist/components/SearchField.js +3 -3
  41. package/dist/components/Select.js +7 -7
  42. package/dist/components/Surface.js +2 -2
  43. package/dist/components/Table.js +7 -7
  44. package/dist/components/Tabs.js +4 -4
  45. package/dist/components/TagGroup.js +2 -2
  46. package/dist/components/TextField.js +6 -6
  47. package/dist/components/TimeField.js +2 -2
  48. package/dist/components/Toggle.d.ts +1 -1
  49. package/dist/components/Toggle.js +2 -2
  50. package/dist/components/Toolbar.js +2 -2
  51. package/dist/components/Tooltip.js +3 -3
  52. package/dist/components/Tree.d.ts +4 -2
  53. package/dist/components/Tree.js +18 -4
  54. package/dist/core/Connection.d.ts +7 -4
  55. package/dist/core/Entry.d.ts +6 -0
  56. package/dist/core/Entry.js +10 -0
  57. package/dist/core/Graph.d.ts +1 -1
  58. package/dist/core/Id.d.ts +1 -0
  59. package/dist/core/Id.js +8 -0
  60. package/dist/core/Infer.d.ts +8 -1
  61. package/dist/core/db/EntryAliases.js +1 -4
  62. package/dist/core/db/EntryResolver.js +6 -6
  63. package/dist/core/db/EntryTransaction.js +1 -0
  64. package/dist/core/db/Operation.d.ts +2 -2
  65. package/dist/core/db/Operation.js +15 -4
  66. package/dist/dashboard/App.js +37 -17
  67. package/dist/dashboard/StoryProvider.js +2 -2
  68. package/dist/dashboard/app/AccessDenied.d.ts +16 -1
  69. package/dist/dashboard/app/AccessDenied.js +21 -12
  70. package/dist/dashboard/app/ActivityStatus.js +19 -19
  71. package/dist/dashboard/app/AppearanceToggle.d.ts +1 -0
  72. package/dist/dashboard/app/AppearanceToggle.js +43 -0
  73. package/dist/dashboard/app/AuthView.d.ts +1 -1
  74. package/dist/dashboard/app/AuthView.js +16 -18
  75. package/dist/dashboard/app/Badge.js +2 -2
  76. package/dist/dashboard/app/CompactField.js +17 -17
  77. package/dist/dashboard/app/DashboardErrorBoundary.js +22 -10
  78. package/dist/dashboard/app/DashboardLayout.js +15 -8
  79. package/dist/dashboard/app/DashboardMeta.d.ts +2 -1
  80. package/dist/dashboard/app/DashboardMeta.js +20 -5
  81. package/dist/dashboard/app/EntryFields.js +6 -6
  82. package/dist/dashboard/app/EntryHeader.js +25 -25
  83. package/dist/dashboard/app/EntryReferences.js +16 -16
  84. package/dist/dashboard/app/EntrySidebar.js +26 -26
  85. package/dist/dashboard/app/EntrySidebarPreview.js +61 -34
  86. package/dist/dashboard/app/EntrySidebarPreview.story.d.ts +6 -1
  87. package/dist/dashboard/app/EntryTranslationBanner.js +8 -8
  88. package/dist/dashboard/app/Explorer.d.ts +2 -1
  89. package/dist/dashboard/app/Explorer.js +79 -67
  90. package/dist/dashboard/app/ExplorerCards.js +62 -66
  91. package/dist/dashboard/app/ExplorerFileCard.js +20 -20
  92. package/dist/dashboard/app/ExplorerList.js +22 -22
  93. package/dist/dashboard/app/ExplorerModal.js +3 -3
  94. package/dist/dashboard/app/ExplorerPickerContent.js +2 -2
  95. package/dist/dashboard/app/ExplorerTable.js +68 -68
  96. package/dist/dashboard/app/ImagePicker.js +7 -7
  97. package/dist/dashboard/app/LinkPicker.js +44 -24
  98. package/dist/dashboard/app/LocaleMenu.js +5 -7
  99. package/dist/dashboard/app/SidebarLayout.js +7 -7
  100. package/dist/dashboard/app/SidebarTree.js +66 -74
  101. package/dist/dashboard/app/WorkspaceMenu.d.ts +10 -3
  102. package/dist/dashboard/app/WorkspaceMenu.js +85 -64
  103. package/dist/dashboard/app/WorkspaceMenu.stories.d.ts +2 -0
  104. package/dist/dashboard/app/WorkspaceRoots.d.ts +3 -1
  105. package/dist/dashboard/app/WorkspaceRoots.js +82 -107
  106. package/dist/dashboard/app/editor/FileEditor.js +31 -31
  107. package/dist/dashboard/app/editor/FilePreview.js +4 -4
  108. package/dist/dashboard/app/editor/MediaAltField.view.js +4 -4
  109. package/dist/dashboard/app/modals/CreateEntry.js +14 -14
  110. package/dist/dashboard/app/pages/EntryPage.js +28 -30
  111. package/dist/dashboard/app/pages/RootPage.js +4 -4
  112. package/dist/dashboard/app/pages/SplashPage.d.ts +3 -0
  113. package/dist/dashboard/app/pages/SplashPage.js +414 -0
  114. package/dist/dashboard/app/pages/UsersPage.js +35 -35
  115. package/dist/dashboard/app/ui/DashboardModal.js +19 -19
  116. package/dist/dashboard/app/ui/Rail.js +3 -3
  117. package/dist/dashboard/atoms/ReactiveNode.js +1 -1
  118. package/dist/dashboard/atoms/activity.js +2 -3
  119. package/dist/dashboard/atoms/auth.d.ts +2 -0
  120. package/dist/dashboard/atoms/auth.js +6 -2
  121. package/dist/dashboard/atoms/config.js +1 -1
  122. package/dist/dashboard/atoms/core.js +2 -2
  123. package/dist/dashboard/atoms/create.js +1 -1
  124. package/dist/dashboard/atoms/dashboard.js +2 -2
  125. package/dist/dashboard/atoms/editor.js +1 -1
  126. package/dist/dashboard/atoms/entry.js +2 -2
  127. package/dist/dashboard/atoms/explorer.d.ts +1 -3
  128. package/dist/dashboard/atoms/explorer.js +7 -9
  129. package/dist/dashboard/atoms/graph.d.ts +1 -0
  130. package/dist/dashboard/atoms/graph.js +7 -2
  131. package/dist/dashboard/atoms/link.js +2 -2
  132. package/dist/dashboard/atoms/nav.d.ts +4 -3
  133. package/dist/dashboard/atoms/nav.js +10 -5
  134. package/dist/dashboard/atoms/preview.js +1 -1
  135. package/dist/dashboard/atoms/root.js +2 -2
  136. package/dist/dashboard/atoms/upload.js +1 -1
  137. package/dist/dashboard/atoms/user.d.ts +1 -1
  138. package/dist/dashboard/atoms/user.js +8 -6
  139. package/dist/dashboard/atoms/utils.js +2 -2
  140. package/dist/dashboard/boot/Boot.js +2 -4
  141. package/dist/dashboard/boot/DashboardWorker.js +34 -29
  142. package/dist/dashboard/editor/UseField.js +6 -6
  143. package/dist/dashboard/fixture/cms.d.ts +12 -0
  144. package/dist/dashboard/fixture/cms.js +53 -2
  145. package/dist/dashboard/hook/UseGraph.js +4 -4
  146. package/dist/dashboard/hook/UseRoot.js +4 -4
  147. package/dist/dashboard/hooks.js +16 -16
  148. package/dist/field/check/CheckField.view.js +2 -2
  149. package/dist/field/code/CodeField.view.js +15 -15
  150. package/dist/field/link/EntryLink.d.ts +1 -1
  151. package/dist/field/link/EntryLink.js +1 -0
  152. package/dist/field/link/Link.js +1 -0
  153. package/dist/field/link/LinkField.d.ts +5 -0
  154. package/dist/field/link/LinkField.view.js +81 -64
  155. package/dist/field/list/ListField.view.js +26 -26
  156. package/dist/field/localiser/LocalisedField.view.js +76 -5
  157. package/dist/field/metadata/MetadataField.d.ts +2 -0
  158. package/dist/field/metadata/MetadataField.js +2 -1
  159. package/dist/field/metadata/MetadataField.view.js +20 -20
  160. package/dist/field/richtext/PickTextLink.js +6 -6
  161. package/dist/field/richtext/RichTextBlock.js +6 -6
  162. package/dist/field/richtext/RichTextBlocks.js +1 -1
  163. package/dist/field/richtext/RichTextExtensions.js +23 -23
  164. package/dist/field/richtext/RichTextField.view.js +9 -9
  165. package/dist/field/richtext/RichTextState.js +1 -1
  166. package/dist/field/text/TextField.view.js +2 -2
  167. package/dist/index.css +436 -28
  168. package/dist/preview/PreviewMessage.d.ts +3 -0
  169. package/dist/preview/PreviewMessage.js +1 -0
  170. package/dist/preview/RegisterPreview.d.ts +1 -1
  171. package/dist/preview/RegisterPreview.js +28 -10
  172. package/dist/preview/react.d.ts +5 -1
  173. package/dist/preview/react.js +12 -9
  174. package/dist/preview/widget.js +6 -12
  175. package/dist/query.d.ts +7 -7
  176. package/package.json +1 -1
  177. package/dist/chunks/chunk-STAJCW4Z.js +0 -322
  178. package/dist/chunks/chunk-U4VOHNR2.js +0 -210
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  unwrap
3
- } from "../../chunks/chunk-STAJCW4Z.js";
3
+ } from "../../chunks/chunk-TIJTT5ZI.js";
4
4
  import {
5
5
  atom
6
- } from "../../chunks/chunk-Y7XOMJOC.js";
6
+ } from "../../chunks/chunk-CFNRVI3Y.js";
7
7
  import "../../chunks/chunk-CQ52GEHY.js";
8
8
 
9
9
  // src/dashboard/atoms/utils.ts
@@ -48,10 +48,8 @@ async function boot(gen) {
48
48
  }
49
49
  const isLocal = worker instanceof DashboardWorker;
50
50
  if (isLocal) await worker.load(batch.revision, batch.config, batch.client);
51
- if (batch.revision !== lastRevision) {
52
- const db = new WorkerDB(batch.config, worker, batch.client, events);
53
- root.render(/* @__PURE__ */ jsx(App, { graph: db, events, ...batch }));
54
- }
51
+ const db = new WorkerDB(batch.config, worker, batch.client, events);
52
+ root.render(/* @__PURE__ */ jsx(App, { graph: db, events, ...batch }));
55
53
  lastRevision = batch.revision;
56
54
  }
57
55
  }
@@ -40,15 +40,25 @@ var DashboardWorker = class extends EventTarget {
40
40
  return this.#localClient ?? this.#nextLoad.then((res) => res.client);
41
41
  }
42
42
  async sync() {
43
- const db = await this.db;
44
- const client = await this.#client;
45
- if (this.#local.activeCount > 0 || this.#local.pendingCount > 0 || remote.activeCount > 0 || remote.pendingCount > 0)
43
+ const load = this.#nextLoad;
44
+ const loaded = await load;
45
+ const { db, client } = loaded;
46
+ return this.#local(async () => {
47
+ try {
48
+ await remote(() => this.#syncWithClient(db, client));
49
+ } catch (error) {
50
+ if (loaded.cacheFailure) {
51
+ throw new AggregateError(
52
+ [loaded.cacheFailure.error, error],
53
+ "Failed to load cached content and fetch remote updates"
54
+ );
55
+ }
56
+ throw error;
57
+ }
58
+ loaded.cacheFailure = void 0;
59
+ this.#startSyncing();
46
60
  return db.sha;
47
- const sourceTree = await db.source.getTree();
48
- if (db.index.tree.isEmpty && !sourceTree.isEmpty) await db.sync();
49
- const sync = remote(() => this.#syncWithClient(db, client));
50
- if (sourceTree.isEmpty) await sync;
51
- return db.sha;
61
+ });
52
62
  }
53
63
  async sha() {
54
64
  return (await this.db).sha;
@@ -100,11 +110,7 @@ var DashboardWorker = class extends EventTarget {
100
110
  const latestFetch = this.#activities.find(
101
111
  (activity) => activity.type === "fetch"
102
112
  );
103
- if (latestFetch?.status === "failed") {
104
- const db = await this.db;
105
- const client = await this.#client;
106
- await remote(() => this.#syncWithClient(db, client));
107
- }
113
+ if (latestFetch?.status === "failed") await this.sync();
108
114
  }
109
115
  async #retryMutations() {
110
116
  await this.#local(async () => {
@@ -257,19 +263,19 @@ var DashboardWorker = class extends EventTarget {
257
263
  return db.referencesTo(query);
258
264
  }
259
265
  async load(revision, config, client) {
260
- if (this.#currentRevision === revision) {
261
- await this.sync();
262
- return;
263
- }
266
+ if (this.#currentRevision === revision) return;
264
267
  this.#currentRevision = revision;
265
- const db = new LocalDB(config, this.#source);
268
+ const nextLoad = this.#localDB ? trigger() : this.#nextLoad;
269
+ this.#nextLoad = nextLoad;
270
+ this.#localDB = void 0;
271
+ this.#localClient = void 0;
266
272
  try {
273
+ const db = new LocalDB(config, this.#source);
267
274
  if (this.#defer) this.#defer();
268
- const cacheReady = await this.#syncLocalIndex(db);
269
- if (!cacheReady) await remote(() => this.#syncWithClient(db, client));
275
+ const cacheFailure = await this.#syncLocalIndex(db);
270
276
  this.#localDB = db;
271
277
  this.#localClient = client;
272
- this.#nextLoad.resolve({ db, client });
278
+ nextLoad.resolve({ db, client, cacheFailure });
273
279
  const listen = (event) => {
274
280
  if (event instanceof IndexEvent)
275
281
  this.dispatchEvent(new IndexEvent(event.data));
@@ -278,29 +284,28 @@ var DashboardWorker = class extends EventTarget {
278
284
  this.#defer = () => {
279
285
  db.index.removeEventListener(IndexEvent.type, listen);
280
286
  };
281
- this.#startSyncing(cacheReady);
282
287
  } catch (cause) {
283
- this.#nextLoad.reject(new Error("Failed to load database", { cause }));
288
+ this.#currentRevision = void 0;
289
+ this.#nextLoad = trigger();
290
+ nextLoad.reject(new Error("Failed to load database", { cause }));
284
291
  throw cause;
285
292
  }
286
293
  }
287
294
  async #syncLocalIndex(db) {
288
295
  const sourceTree = await db.source.getTree();
289
- if (sourceTree.isEmpty) return false;
296
+ if (sourceTree.isEmpty) return;
290
297
  try {
291
298
  await db.sync();
292
- return true;
293
- } catch {
294
- return false;
299
+ } catch (error) {
300
+ return { error };
295
301
  }
296
302
  }
297
- #startSyncing(refreshImmediately) {
303
+ #startSyncing() {
298
304
  if (this.#syncInterval) return;
299
305
  const sync = () => {
300
306
  void this.sync().catch(() => {
301
307
  });
302
308
  };
303
- if (refreshImmediately) sync();
304
309
  this.#syncInterval = setInterval(sync, syncInterval);
305
310
  }
306
311
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
- useAtomValue,
2
+ useAtomValueRaw,
3
3
  useSetAtom
4
- } from "../../chunks/chunk-U4VOHNR2.js";
5
- import "../../chunks/chunk-Y7XOMJOC.js";
4
+ } from "../../chunks/chunk-D6UJHBJJ.js";
5
+ import "../../chunks/chunk-CFNRVI3Y.js";
6
6
  import "../../chunks/chunk-CQ52GEHY.js";
7
7
 
8
8
  // src/dashboard/editor/UseField.ts
@@ -36,15 +36,15 @@ function useFieldKey(field) {
36
36
  }
37
37
  function useFieldOptions(field) {
38
38
  const info = useFieldInfo(field);
39
- return useAtomValue(info.options);
39
+ return useAtomValueRaw(info.options);
40
40
  }
41
41
  function useFieldError(field) {
42
42
  const info = useFieldInfo(field);
43
- return useAtomValue(info.error);
43
+ return useAtomValueRaw(info.error);
44
44
  }
45
45
  function useFieldValue(field) {
46
46
  const info = useFieldInfo(field);
47
- return useAtomValue(info.value);
47
+ return useAtomValueRaw(info.value);
48
48
  }
49
49
  function useFieldMutator(field) {
50
50
  const info = useFieldInfo(field);
@@ -112,5 +112,17 @@ export declare const cms: import("../../adapter/core/cms.js").CoreCMS<{
112
112
  pages: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
113
113
  media: import("../../core/media/MediaRoot.js").MediaRoot<import("../../core/Root.js").ChildrenDefinition>;
114
114
  }>;
115
+ manyRoots: import("alinea").Workspace<{
116
+ pages: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
117
+ articles: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
118
+ documentation: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
119
+ campaigns: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
120
+ translations: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
121
+ archive: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
122
+ settings: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
123
+ brandAssets: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
124
+ nestedContent: import("alinea").Root<import("../../core/Root.js").ChildrenDefinition>;
125
+ media: import("../../core/media/MediaRoot.js").MediaRoot<import("../../core/Root.js").ChildrenDefinition>;
126
+ }>;
115
127
  };
116
128
  }>;
@@ -4,10 +4,17 @@ import "../../chunks/chunk-CQ52GEHY.js";
4
4
  import { createCMS } from "alinea/core";
5
5
  import { Config, Field } from "alinea/index";
6
6
  import {
7
+ IcOutlineFolder,
7
8
  IcOutlineGridView,
9
+ IcOutlineSettings,
10
+ IcRoundDescription,
8
11
  IcRoundHistory,
12
+ IcRoundImage,
13
+ IcRoundLanguage,
14
+ IcRoundPublic,
9
15
  IcRoundTranslate,
10
- MiLayers
16
+ MiLayers,
17
+ LucideFolder
11
18
  } from "../icons.js";
12
19
  var Page = Config.document("Page", {
13
20
  contains: ["Page", "Folder"],
@@ -214,6 +221,49 @@ var statuses = Config.workspace("Statuses", {
214
221
  media: Config.media()
215
222
  }
216
223
  });
224
+ var manyRoots = Config.workspace("Many roots", {
225
+ source: "content/manyRoots",
226
+ icon: LucideFolder,
227
+ roots: {
228
+ pages: Config.root("Pages", {
229
+ contains: ["Page", "Folder"],
230
+ openByDefault: true
231
+ }),
232
+ articles: Config.root("Articles", {
233
+ contains: ["Page", "Folder"],
234
+ icon: IcRoundDescription
235
+ }),
236
+ documentation: Config.root("Documentation", {
237
+ contains: ["Page", "Folder"],
238
+ icon: IcOutlineFolder
239
+ }),
240
+ campaigns: Config.root("Campaigns", {
241
+ contains: ["Page", "Folder"],
242
+ icon: IcRoundPublic
243
+ }),
244
+ translations: Config.root("Translations", {
245
+ contains: ["Page", "Folder"],
246
+ icon: IcRoundLanguage
247
+ }),
248
+ archive: Config.root("Archive", {
249
+ contains: ["Page", "Folder"],
250
+ icon: IcRoundHistory
251
+ }),
252
+ settings: Config.root("Settings", {
253
+ contains: ["Page", "Folder"],
254
+ icon: IcOutlineSettings
255
+ }),
256
+ brandAssets: Config.root("Brand assets", {
257
+ contains: ["Page", "Folder"],
258
+ icon: IcRoundImage
259
+ }),
260
+ nestedContent: Config.root("Nested content", {
261
+ contains: ["Page", "Folder"],
262
+ icon: MiLayers
263
+ }),
264
+ media: Config.media()
265
+ }
266
+ });
217
267
  var cms = createCMS({
218
268
  enableDrafts: true,
219
269
  schema: { Page, Folder },
@@ -222,7 +272,8 @@ var cms = createCMS({
222
272
  nested,
223
273
  many,
224
274
  i18n,
225
- statuses
275
+ statuses,
276
+ manyRoots
226
277
  }
227
278
  });
228
279
  export {
@@ -1,13 +1,13 @@
1
1
  import {
2
- useAtomValue
3
- } from "../../chunks/chunk-U4VOHNR2.js";
4
- import "../../chunks/chunk-Y7XOMJOC.js";
2
+ useAtomValueRaw
3
+ } from "../../chunks/chunk-D6UJHBJJ.js";
4
+ import "../../chunks/chunk-CFNRVI3Y.js";
5
5
  import "../../chunks/chunk-CQ52GEHY.js";
6
6
 
7
7
  // src/dashboard/hook/UseGraph.ts
8
8
  import { graphAtom } from "../atoms/core.js";
9
9
  function useGraph() {
10
- return useAtomValue(graphAtom);
10
+ return useAtomValueRaw(graphAtom);
11
11
  }
12
12
  export {
13
13
  useGraph
@@ -1,14 +1,14 @@
1
1
  import {
2
- useAtomValue
3
- } from "../../chunks/chunk-U4VOHNR2.js";
4
- import "../../chunks/chunk-Y7XOMJOC.js";
2
+ useAtomValueRaw
3
+ } from "../../chunks/chunk-D6UJHBJJ.js";
4
+ import "../../chunks/chunk-CFNRVI3Y.js";
5
5
  import "../../chunks/chunk-CQ52GEHY.js";
6
6
 
7
7
  // src/dashboard/hook/UseRoot.ts
8
8
  import { useDashboardContext } from "../hooks.js";
9
9
  function useRoot() {
10
10
  const { root } = useDashboardContext();
11
- return { name: root.key, ...useAtomValue(root.data) };
11
+ return { name: root.key, ...useAtomValueRaw(root.data) };
12
12
  }
13
13
  export {
14
14
  useRoot
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Provider,
3
3
  useAtom,
4
- useAtomValue,
4
+ useAtomValueRaw,
5
5
  useSetAtom
6
- } from "../chunks/chunk-U4VOHNR2.js";
6
+ } from "../chunks/chunk-D6UJHBJJ.js";
7
7
  import {
8
8
  atom,
9
9
  createStore
10
- } from "../chunks/chunk-Y7XOMJOC.js";
10
+ } from "../chunks/chunk-CFNRVI3Y.js";
11
11
  import "../chunks/chunk-CQ52GEHY.js";
12
12
 
13
13
  // src/dashboard/hooks.tsx
@@ -69,16 +69,16 @@ function useDashboard() {
69
69
  return dashboard;
70
70
  }
71
71
  function usePolicy() {
72
- return useAtomValue(policyAtom);
72
+ return useAtomValueRaw(policyAtom);
73
73
  }
74
74
  function useUser() {
75
- return useAtomValue(userAtom);
75
+ return useAtomValueRaw(userAtom);
76
76
  }
77
77
  function useGraph() {
78
- return useAtomValue(graphAtom);
78
+ return useAtomValueRaw(graphAtom);
79
79
  }
80
80
  function usePreviewMetadata() {
81
- return useAtomValue(previewMetadataAtom);
81
+ return useAtomValueRaw(previewMetadataAtom);
82
82
  }
83
83
  function EditorScope({
84
84
  children,
@@ -132,7 +132,7 @@ function useFieldInfo(field) {
132
132
  function useNodeEditor(node, type) {
133
133
  const parent = useContext(editorContext);
134
134
  const scope = useContext(entryContext);
135
- const policy = useAtomValue(scope ? policyAtom : noPolicyAtom);
135
+ const policy = useAtomValueRaw(scope ? policyAtom : noPolicyAtom);
136
136
  const activeVersion = scope?.selectedEntry;
137
137
  const editor = useMemo(() => {
138
138
  return new EntryEditor(
@@ -149,17 +149,17 @@ function useNodeEditor(node, type) {
149
149
  function useFieldNode(field) {
150
150
  const key = useFieldKey(field);
151
151
  const editor = useEditor();
152
- const nodes = useAtomValue(editor.node.nodes);
152
+ const nodes = useAtomValueRaw(editor.node.nodes);
153
153
  assert(nodes[key], `Node not found for field key: ${key}`);
154
154
  return nodes[key];
155
155
  }
156
156
  function useFieldValue(field) {
157
157
  const node = useFieldNode(field);
158
- return useAtomValue(node.value);
158
+ return useAtomValueRaw(node.value);
159
159
  }
160
160
  function useField(field) {
161
161
  const info = useFieldInfo(field);
162
- const value = useAtomValue(info.value);
162
+ const value = useAtomValueRaw(info.value);
163
163
  const setValue = useSetAtom(info.value);
164
164
  return [value, setValue];
165
165
  }
@@ -173,21 +173,21 @@ function useFieldKey(field) {
173
173
  }
174
174
  function useFieldOptions(field) {
175
175
  const info = useFieldInfo(field);
176
- return useAtomValue(info.options);
176
+ return useAtomValueRaw(info.options);
177
177
  }
178
178
  function useFieldError(field) {
179
179
  const info = useFieldInfo(field);
180
- return useAtomValue(info.error);
180
+ return useAtomValueRaw(info.error);
181
181
  }
182
182
  function useFieldView(field) {
183
183
  const info = useFieldInfo(field);
184
- return useAtomValue(info.view);
184
+ return useAtomValueRaw(info.view);
185
185
  }
186
186
  function useSiblingFieldValue(key) {
187
187
  const editor = useEditor();
188
188
  const info = editor.field(key);
189
189
  assert(info, `Field not found: ${key}`);
190
- return useAtomValue(info.value);
190
+ return useAtomValueRaw(info.value);
191
191
  }
192
192
  function useEntryModel() {
193
193
  return useContext(entryContext);
@@ -200,7 +200,7 @@ function useValue(node) {
200
200
  return useAtom(node.value);
201
201
  }
202
202
  function useNodes(node) {
203
- return useAtomValue(node.nodes);
203
+ return useAtomValueRaw(node.nodes);
204
204
  }
205
205
  export {
206
206
  DashboardModelScope,
@@ -9,9 +9,9 @@ import { useField, useFieldError, useFieldOptions } from "alinea/dashboard/hooks
9
9
 
10
10
  // src/field/check/CheckField.module.css
11
11
  var CheckField_default = {
12
- "checkline": "alinea-checkline",
13
12
  "checkline-required": "alinea-checkline-required",
14
- "checklineRequired": "alinea-checkline-required"
13
+ "checklineRequired": "alinea-checkline-required",
14
+ "checkline": "alinea-checkline"
15
15
  };
16
16
 
17
17
  // src/field/check/CheckField.view.tsx
@@ -64,27 +64,27 @@ import { Fragment, useId } from "react";
64
64
 
65
65
  // src/field/code/CodeField.module.css
66
66
  var CodeField_default = {
67
- "CodeEditorInput": "alinea-CodeEditorInput",
68
- "CodeEditorInput-pre": "alinea-CodeEditorInput-pre",
69
- "CodeEditorInputPre": "alinea-CodeEditorInput-pre",
70
- "CodeEditorInput-keyword": "alinea-CodeEditorInput-keyword",
71
- "CodeEditorInputKeyword": "alinea-CodeEditorInput-keyword",
72
- "CodeEditorInput-string": "alinea-CodeEditorInput-string",
73
- "CodeEditorInputString": "alinea-CodeEditorInput-string",
67
+ "CodeEditorInput-identifier": "alinea-CodeEditorInput-identifier",
68
+ "CodeEditorInputIdentifier": "alinea-CodeEditorInput-identifier",
69
+ "CodeEditorInput-textarea": "alinea-CodeEditorInput-textarea",
70
+ "CodeEditorInputTextarea": "alinea-CodeEditorInput-textarea",
74
71
  "CodeEditorInput-number": "alinea-CodeEditorInput-number",
75
72
  "CodeEditorInputNumber": "alinea-CodeEditorInput-number",
76
- "CodeEditorInput-editor": "alinea-CodeEditorInput-editor",
77
- "CodeEditorInputEditor": "alinea-CodeEditorInput-editor",
73
+ "CodeEditorInput-string": "alinea-CodeEditorInput-string",
74
+ "CodeEditorInputString": "alinea-CodeEditorInput-string",
78
75
  "CodeEditorInput-regex": "alinea-CodeEditorInput-regex",
79
76
  "CodeEditorInputRegex": "alinea-CodeEditorInput-regex",
80
- "CodeEditorInput-punctuation": "alinea-CodeEditorInput-punctuation",
81
- "CodeEditorInputPunctuation": "alinea-CodeEditorInput-punctuation",
82
77
  "CodeEditorInput-comment": "alinea-CodeEditorInput-comment",
83
78
  "CodeEditorInputComment": "alinea-CodeEditorInput-comment",
84
- "CodeEditorInput-identifier": "alinea-CodeEditorInput-identifier",
85
- "CodeEditorInputIdentifier": "alinea-CodeEditorInput-identifier",
86
- "CodeEditorInput-textarea": "alinea-CodeEditorInput-textarea",
87
- "CodeEditorInputTextarea": "alinea-CodeEditorInput-textarea"
79
+ "CodeEditorInput-editor": "alinea-CodeEditorInput-editor",
80
+ "CodeEditorInputEditor": "alinea-CodeEditorInput-editor",
81
+ "CodeEditorInput-pre": "alinea-CodeEditorInput-pre",
82
+ "CodeEditorInputPre": "alinea-CodeEditorInput-pre",
83
+ "CodeEditorInput-punctuation": "alinea-CodeEditorInput-punctuation",
84
+ "CodeEditorInputPunctuation": "alinea-CodeEditorInput-punctuation",
85
+ "CodeEditorInput-keyword": "alinea-CodeEditorInput-keyword",
86
+ "CodeEditorInputKeyword": "alinea-CodeEditorInput-keyword",
87
+ "CodeEditorInput": "alinea-CodeEditorInput"
88
88
  };
89
89
 
90
90
  // src/field/code/CodeField.view.tsx
@@ -30,7 +30,7 @@ export declare namespace entry {
30
30
  type EntryRow<Fields> = EntryLink<Type.Infer<Fields>> & ListRow;
31
31
  interface EntryOptions<Fields> extends LinkFieldOptions<Array<EntryReference & ListRow & InferStoredValue<Fields>>>, Omit<EntryPickerOptions<Fields>, 'label' | 'selection'> {
32
32
  }
33
- export function multiple<Fields = undefined>(label: Label, options?: WithoutLabel<EntryOptions<Fields>>): import("alinea/field/link/LinkField").LinksField<EntryReference & ListRow, EntryRow<Fields>>;
33
+ export function multiple<Fields = undefined>(label: Label, options?: WithoutLabel<EntryOptions<Fields>>): import("alinea/field/link/LinkField").LinksField<EntryReference & ListRow & InferStoredValue<Fields>, EntryRow<Fields>>;
34
34
  export {};
35
35
  }
36
36
  export {};
@@ -33,6 +33,7 @@ function entry(label, options = {}) {
33
33
  ((entry2) => {
34
34
  function multiple(label, options = {}) {
35
35
  return createLinks(label, {
36
+ allowDuplicates: false,
36
37
  ...options,
37
38
  isEntryField: true,
38
39
  pickers: {
@@ -27,6 +27,7 @@ function link(label, options = {}) {
27
27
  ((link2) => {
28
28
  function multiple(label, options = {}) {
29
29
  return createLinks(label, {
30
+ allowDuplicates: true,
30
31
  ...options,
31
32
  pickers: {
32
33
  entry: entryPicker({
@@ -8,6 +8,11 @@ import { ListRow } from 'alinea/core/ListRow';
8
8
  import type { ReactNode } from 'react';
9
9
  /** Optional settings to configure a link field */
10
10
  export interface LinkFieldOptions<Value> extends FieldOptions<Value> {
11
+ /**
12
+ * Allow the same entry to be linked more than once.
13
+ * Defaults to false for entry fields and true for generic link fields.
14
+ */
15
+ allowDuplicates?: boolean;
11
16
  /** Width of the field in the dashboard UI (0-1) */
12
17
  width?: number;
13
18
  /** Add instructional text to a field */