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.
- package/dist/backend/Store.js +1 -1
- package/dist/chunks/{chunk-QV233D56.js → chunk-VRXHB6DJ.js} +5 -3
- package/dist/chunks/{chunk-IG7UQXAE.js → chunk-YTMQVHQU.js} +1 -1
- package/dist/chunks/{sql.js-OZNQGHQS.js → sql.js-75HGQX6U.js} +1 -1
- package/dist/cli/Generate.js +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/generate/GenerateDashboard.js +1 -1
- package/dist/cloud/server/CloudAuthServer.js +1 -1
- package/dist/core/driver/TestDriver.js +1 -1
- package/dist/dashboard/util/PersistentStore.js +1 -1
- package/dist/dashboard/view/entry/NewEntry.js +2 -1
- package/dist/dashboard/view/media/FileSummary.js +2 -2
- package/dist/input/link/LinkField.browser.js +28 -18
- package/dist/input/number/NumberField.browser.js +25 -9
- package/dist/input/select/SelectField.browser.js +1 -1
- package/dist/picker/url/UrlPicker.browser.d.ts +1 -1
- package/dist/picker/url/UrlPicker.browser.js +13 -5
- package/package.json +1 -1
package/dist/backend/Store.js
CHANGED
|
@@ -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(
|
|
414
|
+
this.lock = Promise.resolve(currentLock).then(() => trigger);
|
|
415
|
+
await currentLock;
|
|
414
416
|
return [connection, release];
|
|
415
417
|
}
|
|
416
418
|
};
|
package/dist/cli/Generate.js
CHANGED
|
@@ -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-
|
|
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
package/dist/cli/bin.js
CHANGED
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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) =>
|
|
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__ */
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
33
|
-
onChange: (
|
|
34
|
-
|
|
47
|
+
defaultValue,
|
|
48
|
+
onChange: ({ currentTarget }) => {
|
|
49
|
+
const value2 = tryParseNumber(currentTarget.value);
|
|
50
|
+
mutator(value2);
|
|
35
51
|
},
|
|
36
|
-
onBlur: () => {
|
|
37
|
-
const
|
|
38
|
-
mutator(
|
|
39
|
-
|
|
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("
|
|
28
|
-
description: "
|
|
27
|
+
blank: check("Target", {
|
|
28
|
+
description: "Open link in new tab",
|
|
29
29
|
initialValue: true
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
|
-
function UrlPickerForm({
|
|
33
|
-
|
|
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,
|