alinea 0.5.1 → 0.5.3

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,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "../chunks/chunk-QV233D56.js";
3
+ } from "../chunks/chunk-VRXHB6DJ.js";
4
4
  import "../chunks/chunk-FLZ4KUMA.js";
5
5
  import "../chunks/chunk-4JLFL6LD.js";
6
6
  import "../chunks/chunk-U5RRZUYZ.js";
@@ -336,7 +336,7 @@ var AsyncDriver = class extends DriverBase {
336
336
  }
337
337
  async transaction(run) {
338
338
  const id = `t${this.transactionId++}`;
339
- const [connection, release] = this.isolate();
339
+ const [connection, release] = await this.isolate();
340
340
  await connection.executeQuery(
341
341
  new QueryData.Transaction({ op: QueryData.TransactionOperation.Begin, id })
342
342
  );
@@ -405,12 +405,14 @@ var SyncWrapper = class _SyncWrapper extends AsyncDriver {
405
405
  async schemaInstructions(tableName) {
406
406
  return this.sync.schemaInstructions(tableName);
407
407
  }
408
- isolate() {
408
+ async isolate() {
409
+ const currentLock = this.lock;
409
410
  const connection = new _SyncWrapper(this.sync);
410
411
  let release, trigger = new Promise((resolve) => {
411
412
  release = async () => resolve();
412
413
  });
413
- this.lock = Promise.resolve(this.lock).then(() => trigger);
414
+ this.lock = Promise.resolve(currentLock).then(() => trigger);
415
+ await currentLock;
414
416
  return [connection, release];
415
417
  }
416
418
  };
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.5.1",
5
+ version: "0.5.3",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SqlJsDriver,
3
3
  connect
4
- } from "./chunk-QV233D56.js";
4
+ } from "./chunk-VRXHB6DJ.js";
5
5
  import "./chunk-FLZ4KUMA.js";
6
6
  import "./chunk-4JLFL6LD.js";
7
7
  import "./chunk-U5RRZUYZ.js";
@@ -27,7 +27,7 @@ function generatePackage(context, config) {
27
27
  async function createDb() {
28
28
  const { default: sqlite } = await import("@alinea/sqlite-wasm");
29
29
  const { Database } = await sqlite();
30
- const { connect } = await import("../chunks/sql.js-OZNQGHQS.js");
30
+ const { connect } = await import("../chunks/sql.js-75HGQX6U.js");
31
31
  const db = new Database();
32
32
  const store = connect(db).toAsync();
33
33
  return [store, () => db.export()];
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-IG7UQXAE.js";
3
+ } from "../chunks/chunk-YTMQVHQU.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-IG7UQXAE.js";
3
+ } from "../chunks/chunk-YTMQVHQU.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-IG7UQXAE.js";
3
+ } from "../../chunks/chunk-YTMQVHQU.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-IG7UQXAE.js";
6
+ } from "../../chunks/chunk-YTMQVHQU.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "../../chunks/chunk-QV233D56.js";
3
+ } from "../../chunks/chunk-VRXHB6DJ.js";
4
4
  import "../../chunks/chunk-FLZ4KUMA.js";
5
5
  import "../../chunks/chunk-4JLFL6LD.js";
6
6
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-7YXWNKGS.js";
4
4
  import {
5
5
  connect
6
- } from "../../chunks/chunk-QV233D56.js";
6
+ } from "../../chunks/chunk-VRXHB6DJ.js";
7
7
  import "../../chunks/chunk-FLZ4KUMA.js";
8
8
  import {
9
9
  create,
@@ -169,8 +169,9 @@ function NewEntryForm({ parentId }) {
169
169
  path,
170
170
  phase: config.enableDrafts ? EntryPhase.Draft : EntryPhase.Published
171
171
  };
172
+ const parentId2 = form.data().parent?.entry;
172
173
  const parent = await graph.preferDraft.get(
173
- Entry({ entryId: parentId }).select(parentData)
174
+ Entry({ entryId: parentId2 }).select(parentData)
174
175
  );
175
176
  const parentPaths = parent ? parent.parentPaths.concat(parent.path) : [];
176
177
  const filePath = entryFilepath(config, data, parentPaths);
@@ -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,
@@ -6,7 +6,7 @@ import { useField } from "alinea/dashboard/editor/UseField";
6
6
  import { InputLabel } from "alinea/dashboard/view/InputLabel";
7
7
  import { fromModule } from "alinea/ui";
8
8
  import { IcRoundNumbers } from "alinea/ui/icons/IcRoundNumbers";
9
- import { useState } from "react";
9
+ import { useEffect, useRef } from "react";
10
10
  import { number as createNumber } from "./NumberField.js";
11
11
 
12
12
  // src/input/number/NumberInput.module.scss
@@ -20,23 +20,39 @@ export * from "./NumberField.js";
20
20
  import { jsx } from "react/jsx-runtime";
21
21
  var number = Field.provideView(NumberInput, createNumber);
22
22
  var styles = fromModule(NumberInput_module_default);
23
+ function tryParseNumber(input) {
24
+ const value = parseFloat(input);
25
+ return isNaN(value) ? null : value;
26
+ }
23
27
  function NumberInput({ field }) {
24
28
  const { options, value, mutator } = useField(field);
25
- const [current, setCurrent] = useState(String(value ?? ""));
26
29
  const { minValue, maxValue, readOnly, step } = options;
30
+ const ref = useRef(null);
31
+ const defaultValue = String(value ?? "");
32
+ useEffect(() => {
33
+ const input = ref.current;
34
+ if (!input)
35
+ return;
36
+ const currentInput = tryParseNumber(input.value);
37
+ if (currentInput === value)
38
+ return;
39
+ input.value = defaultValue;
40
+ }, [defaultValue]);
27
41
  return /* @__PURE__ */ jsx(InputLabel, { asLabel: true, ...options, icon: IcRoundNumbers, children: /* @__PURE__ */ jsx(
28
42
  "input",
29
43
  {
30
44
  type: "number",
45
+ ref,
31
46
  className: styles.root.input(),
32
- value: current,
33
- onChange: (e) => {
34
- setCurrent(e.currentTarget.value);
47
+ defaultValue,
48
+ onChange: ({ currentTarget }) => {
49
+ const value2 = tryParseNumber(currentTarget.value);
50
+ mutator(value2);
35
51
  },
36
- onBlur: () => {
37
- const newValue = current ? parseFloat(current) : null;
38
- mutator(newValue);
39
- setCurrent(String(newValue ?? ""));
52
+ onBlur: ({ currentTarget }) => {
53
+ const value2 = tryParseNumber(currentTarget.value);
54
+ mutator(value2);
55
+ currentTarget.value = String(value2 ?? "");
40
56
  },
41
57
  min: minValue,
42
58
  max: maxValue,
@@ -65,7 +65,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
65
65
  var select = Field.provideView(SelectInput, createSelect);
66
66
  var styles = fromModule(SelectInput_module_default);
67
67
  function SelectInput({ field }) {
68
- const { value, mutator, label, options } = useField(field);
68
+ const { value = null, mutator, label, options } = useField(field);
69
69
  const items = options.items;
70
70
  const { x, y, reference, floating, refs, strategy } = useFloating({
71
71
  whileElementsMounted: autoUpdate,
@@ -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.1",
4
+ "version": "0.5.3",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {