alinea 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.5.0",
5
+ version: "0.5.2",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-B6H4DO6X.js";
3
+ } from "../chunks/chunk-KWP47LDR.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-B6H4DO6X.js";
3
+ } from "../chunks/chunk-KWP47LDR.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-B6H4DO6X.js";
3
+ } from "../../chunks/chunk-KWP47LDR.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
@@ -1,4 +1,3 @@
1
- import {CMS} from 'alinea/core'
2
1
  import {Client} from 'alinea/core/Client'
3
2
  import 'alinea/css'
4
3
  import {App} from 'alinea/dashboard/App'
@@ -19,8 +18,7 @@ export async function boot(handlerUrl) {
19
18
  async function loadConfig() {
20
19
  const configModule = './config.js?' + Math.random()
21
20
  const exports = await import(configModule)
22
- for (const member of Object.values(exports)) {
23
- if (member instanceof CMS) return member
24
- }
21
+ if ('cms' in exports) return exports.cms.config
22
+ if ('config' in exports) return exports.config
25
23
  throw new Error(`No config found in "/config.js"`)
26
24
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-B6H4DO6X.js";
6
+ } from "../../chunks/chunk-KWP47LDR.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -1,6 +1,6 @@
1
1
  import { Store } from 'alinea/backend/Store';
2
2
  import { Resolver } from 'alinea/core';
3
- import { Config, DashboardConfig } from './Config.js';
3
+ import { Config } from './Config.js';
4
4
  import { Graph, GraphRealm, GraphRealmApi } from './Graph.js';
5
5
  import { Root } from './Root.js';
6
6
  import { Workspace } from './Workspace.js';
@@ -10,7 +10,6 @@ export interface CMSApi extends GraphRealmApi {
10
10
  }
11
11
  export declare abstract class CMS extends GraphRealm implements CMSApi {
12
12
  #private;
13
- dashboard: DashboardConfig;
14
13
  graph: Graph;
15
14
  config: Config;
16
15
  constructor(config: Config);
package/dist/core/CMS.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/CMS.ts
4
- import { CloudAuthView } from "alinea/cloud/view/CloudAuth";
5
4
  import { createConfig } from "./Config.js";
6
5
  import { Graph, GraphRealm } from "./Graph.js";
7
6
  import { entries } from "./util/Objects.js";
8
7
  var attached = /* @__PURE__ */ new WeakMap();
9
8
  var CMS = class extends GraphRealm {
10
- dashboard;
11
9
  graph;
12
10
  config;
13
11
  constructor(config) {
@@ -17,10 +15,6 @@ var CMS = class extends GraphRealm {
17
15
  return cnx.resolve(params);
18
16
  });
19
17
  this.config = normalizedConfig;
20
- this.dashboard = {
21
- auth: CloudAuthView,
22
- ...config.dashboard
23
- };
24
18
  this.graph = new Graph(normalizedConfig, async (params) => {
25
19
  const { resolve } = await this.resolver();
26
20
  return resolve(params);
@@ -1,3 +1,4 @@
1
+ import { CloudAuthView } from 'alinea/cloud/view/CloudAuth';
1
2
  import { ComponentType } from 'react';
2
3
  import { Auth } from './Auth.js';
3
4
  import { Entry } from './Entry.js';
@@ -61,4 +62,10 @@ export declare function createConfig<Definition extends Config>(definition: Defi
61
62
  thumbHash: import("../input/hidden.js").HiddenField<string>;
62
63
  }>;
63
64
  };
65
+ dashboard: {
66
+ handlerUrl?: string | undefined;
67
+ dashboardUrl?: string | undefined;
68
+ auth: typeof CloudAuthView | Auth.View;
69
+ staticFile?: string | undefined;
70
+ };
64
71
  };
@@ -1,6 +1,7 @@
1
1
  import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/Config.ts
4
+ import { CloudAuthView } from "alinea/cloud/view/CloudAuth";
4
5
  import { MediaSchema } from "alinea/core/media/MediaSchema";
5
6
  import { Workspace } from "./Workspace.js";
6
7
  var Config;
@@ -22,7 +23,11 @@ var Config;
22
23
  function createConfig(definition) {
23
24
  return {
24
25
  ...definition,
25
- schema: { ...MediaSchema, ...definition.schema }
26
+ schema: { ...MediaSchema, ...definition.schema },
27
+ dashboard: {
28
+ auth: CloudAuthView,
29
+ ...definition.dashboard
30
+ }
26
31
  };
27
32
  }
28
33
  export {
@@ -120,9 +120,9 @@ var FileSummaryThumb = view(
120
120
  /* @__PURE__ */ jsxs("div", { className: styles.thumb.footer(), children: [
121
121
  /* @__PURE__ */ jsx("p", { className: styles.thumb.footer.title(), children: renderLabel(file.title) }),
122
122
  /* @__PURE__ */ jsxs("p", { className: styles.thumb.footer.details(), children: [
123
- file.extension.slice(1).toUpperCase(),
123
+ file.extension?.slice(1).toUpperCase(),
124
124
  file.width && file.height && ` - ${file.width}x${file.height}`,
125
- /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" }, children: prettyBytes(file.size) })
125
+ file.size && /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" }, children: prettyBytes(file.size) })
126
126
  ] })
127
127
  ] })
128
128
  ] });
@@ -30,6 +30,7 @@ import { TextLabel, fromModule } from "alinea/ui";
30
30
  import { Sink } from "alinea/ui/Sink";
31
31
  import { IcRoundClose } from "alinea/ui/icons/IcRoundClose";
32
32
  import IcRoundDragHandle from "alinea/ui/icons/IcRoundDragHandle";
33
+ import { IcRoundEdit } from "alinea/ui/icons/IcRoundEdit";
33
34
  import { IcRoundLink } from "alinea/ui/icons/IcRoundLink";
34
35
  import { Suspense, useState } from "react";
35
36
  import {
@@ -100,7 +101,8 @@ function LinkInput({ field }) {
100
101
  fields: options.pickers[value.type].fields,
101
102
  picker: options.pickers[value.type],
102
103
  reference: value,
103
- onRemove: () => mutator.replace(void 0)
104
+ onRemove: () => mutator.replace(void 0),
105
+ onEdit: () => setPickFrom(value.type)
104
106
  }
105
107
  ) : /* @__PURE__ */ jsx("div", { className: styles.create(), children: /* @__PURE__ */ jsx(Create.Root, { children: entries(options.pickers).map(([name, picker2]) => {
106
108
  return /* @__PURE__ */ jsx(
@@ -125,28 +127,24 @@ function LinksInput({
125
127
  const { options, value, mutator, label } = useField(field);
126
128
  const { width, inline, optional, help } = options;
127
129
  const [pickFrom, setPickFrom] = useState();
128
- const picker = pickFrom ? options.pickers[pickFrom] : void 0;
130
+ const picker = pickFrom ? options.pickers[pickFrom.type] : void 0;
129
131
  function handleConfirm(links) {
130
132
  if (!pickFrom || !picker || !links)
131
133
  return;
132
134
  const seen = /* @__PURE__ */ new Set();
133
135
  for (const link of links) {
134
- if (link.type !== pickFrom)
136
+ if (link.type !== pickFrom.type)
135
137
  continue;
136
138
  seen.add(link.id);
137
- if (picker.handlesMultiple) {
138
- const index = value.findIndex((v) => v.id === link.id);
139
- if (index > -1)
140
- mutator.replace(link.id, link);
141
- else
142
- mutator.push(link);
143
- } else {
139
+ const index = value.findIndex((v) => v.id === link.id);
140
+ if (index > -1)
141
+ mutator.replace(link.id, link);
142
+ else
144
143
  mutator.push(link);
145
- }
146
144
  }
147
145
  if (picker.handlesMultiple)
148
146
  for (const link of value) {
149
- if (link.type !== pickFrom)
147
+ if (link.type !== pickFrom.type)
150
148
  continue;
151
149
  if (seen.has(link.id))
152
150
  continue;
@@ -176,12 +174,18 @@ function LinksInput({
176
174
  const showLinkPicker = options.max ? value.length < options.max : true;
177
175
  const PickerView = picker && picker.view;
178
176
  return /* @__PURE__ */ jsxs(Fragment, { children: [
179
- PickerView && /* @__PURE__ */ jsx(
177
+ pickFrom && PickerView && /* @__PURE__ */ jsx(
180
178
  PickerView,
181
179
  {
182
- type: pickFrom,
180
+ type: pickFrom.type,
183
181
  options: picker.options,
184
- selection: value.filter((ref) => ref.type === pickFrom),
182
+ selection: value.filter((ref) => {
183
+ if (ref.id === pickFrom.id)
184
+ return true;
185
+ if (picker.handlesMultiple)
186
+ return ref.type === pickFrom.type;
187
+ return false;
188
+ }),
185
189
  onConfirm: handleConfirm,
186
190
  onCancel: () => setPickFrom(void 0)
187
191
  }
@@ -223,6 +227,7 @@ function LinksInput({
223
227
  picker: options.pickers[reference.type],
224
228
  reference,
225
229
  onRemove: () => mutator.remove(reference.id),
230
+ onEdit: () => setPickFrom(reference),
226
231
  isSortable: options.max !== 1
227
232
  },
228
233
  reference.id
@@ -232,7 +237,7 @@ function LinksInput({
232
237
  return /* @__PURE__ */ jsx(
233
238
  Create.Button,
234
239
  {
235
- onClick: () => setPickFrom(name),
240
+ onClick: () => setPickFrom({ type: name }),
236
241
  children: /* @__PURE__ */ jsx(TextLabel, { label: picker2.label })
237
242
  },
238
243
  name
@@ -257,6 +262,7 @@ function LinksInput({
257
262
  picker: options.pickers[dragging.type],
258
263
  reference: dragging,
259
264
  onRemove: () => mutator.remove(dragging.id),
265
+ onEdit: () => setPickFrom(dragging),
260
266
  isDragOverlay: true,
261
267
  isSortable: options.max !== 1
262
268
  }
@@ -303,6 +309,7 @@ function LinkInputRow({
303
309
  picker,
304
310
  fields,
305
311
  reference,
312
+ onEdit,
306
313
  onRemove,
307
314
  handle,
308
315
  rootRef,
@@ -332,7 +339,10 @@ function LinkInputRow({
332
339
  }
333
340
  ) : /* @__PURE__ */ jsx("div", { className: styles.row.staticHandle(), children: /* @__PURE__ */ jsx(IcRoundLink, {}) }) }),
334
341
  /* @__PURE__ */ jsx("div", { style: { flexGrow: 1, minWidth: 0 }, children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(RowView, { reference }) }) }),
335
- /* @__PURE__ */ jsx(Sink.Options, { children: /* @__PURE__ */ jsx(IconButton, { icon: IcRoundClose, onClick: onRemove }) })
342
+ /* @__PURE__ */ jsxs(Sink.Options, { children: [
343
+ /* @__PURE__ */ jsx(IconButton, { icon: IcRoundEdit, onClick: onEdit }),
344
+ /* @__PURE__ */ jsx(IconButton, { icon: IcRoundClose, onClick: onRemove })
345
+ ] })
336
346
  ] }),
337
347
  fields && /* @__PURE__ */ jsx(Sink.Content, { children: /* @__PURE__ */ jsx(InputForm, { type: fields }) })
338
348
  ]
@@ -340,7 +350,7 @@ function LinkInputRow({
340
350
  );
341
351
  if (!fields)
342
352
  return inner;
343
- return /* @__PURE__ */ jsx(FormRow, { field, rowId, type: fields, children: inner });
353
+ return /* @__PURE__ */ jsx(FormRow, { field, type: fields, children: inner });
344
354
  }
345
355
  export {
346
356
  createLink,
@@ -2,5 +2,5 @@ import { PickerProps } from 'alinea/core';
2
2
  import { urlPicker as createUrlPicker } from './UrlPicker.js';
3
3
  export * from './UrlPicker.js';
4
4
  export declare const urlPicker: typeof createUrlPicker;
5
- export declare function UrlPickerForm({ options, onConfirm, onCancel }: PickerProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function UrlPickerForm({ selection, options, onConfirm, onCancel }: PickerProps): import("react/jsx-runtime").JSX.Element;
6
6
  export declare function UrlPickerModal(props: PickerProps): import("react/jsx-runtime").JSX.Element;
@@ -24,19 +24,27 @@ var linkForm = type("Link", {
24
24
  optional: true,
25
25
  help: "Text to display inside the link element"
26
26
  }),
27
- blank: check("Open link in new tab", {
28
- description: "Target",
27
+ blank: check("Target", {
28
+ description: "Open link in new tab",
29
29
  initialValue: true
30
30
  })
31
31
  });
32
- function UrlPickerForm({ options, onConfirm, onCancel }) {
33
- const form = useForm(linkForm, { initialValue: options });
32
+ function UrlPickerForm({
33
+ selection,
34
+ options,
35
+ onConfirm,
36
+ onCancel
37
+ }) {
38
+ const preSelected = selection?.[0];
39
+ const form = useForm(linkForm, {
40
+ initialValue: preSelected ? { ...preSelected, blank: preSelected.target === "_blank" } : void 0
41
+ });
34
42
  function handleSubmit(e) {
35
43
  e.preventDefault();
36
44
  e.stopPropagation();
37
45
  const data = form.data();
38
46
  const reference = {
39
- id: createId(),
47
+ id: preSelected?.id ?? createId(),
40
48
  type: "url",
41
49
  ref: "url",
42
50
  url: data.url,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {