@zoobzio/nuxt 0.1.12 → 0.1.13
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/README.md +16 -6
- package/app/app.d.ts +2 -0
- package/app/components/browser.ts +7 -1
- package/app/components/calendar.ts +9 -1
- package/app/components/editor-tool.ts +20 -3
- package/app/components/editor.ts +8 -1
- package/app/components/rich-text.ts +7 -1
- package/app/components/sync.ts +40 -0
- package/app/components/table.ts +8 -1
- package/app/components/timeline.ts +36 -0
- package/app/constants/editor.ts +18 -3
- package/app/constants/views.ts +21 -1
- package/app/factories/browser.ts +19 -4
- package/app/factories/calendar.ts +19 -3
- package/app/factories/table.ts +9 -2
- package/app/factories/timeline.ts +81 -0
- package/app/stores/browser.ts +5 -3
- package/app/stores/timeline.ts +24 -0
- package/app/types/browser.ts +3 -1
- package/app/types/table.ts +3 -1
- package/app/types/timeline.ts +42 -0
- package/app/types/views.ts +7 -0
- package/app/utils/editor.ts +13 -1
- package/modules/imports/constant.ts +28 -1
- package/package.json +16 -14
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ input's remove button, `image` in an image input's placeholder and
|
|
|
150
150
|
in a checkbox, and `indeterminate` in its place while the checkbox is neither on nor off, as a table's or a browser's select-all is over some of its rows; the editor's and rich text's tools by key (`bold`,
|
|
151
151
|
`bullet-list`, `undo`, …, see `EDITOR_TOOL_ICONS`), each drawn in place
|
|
152
152
|
of the button's text so the toolbar is icon-only, with the tool's label in
|
|
153
|
-
the visitor's locale as the button's accessible name and its `title`, and
|
|
153
|
+
the visitor's locale as the button's accessible name and its `title`, the labels of the link's and the image's prompt (see `EDITOR_FIELD_TEXT`) in that locale too, and
|
|
154
154
|
`expand` after the block type dropdown's text, which reads in the
|
|
155
155
|
visitor's locale as its entries do; the calendar's steps by key (`prev`,
|
|
156
156
|
`next`, see `CALENDAR_TOOL_ICONS`), drawn the same way, while today and
|
|
@@ -424,8 +424,16 @@ const users = useUsers(() => ({
|
|
|
424
424
|
| `createEditor` | `accessEditor` | `editor:loaded`, `editor:updated`, `editor:mounted`, `editor:unmounted` |
|
|
425
425
|
| `createCode` | `accessCode` | `code:loaded`, `code:updated`, `code:mounted`, `code:unmounted` |
|
|
426
426
|
| `createCalendar` | `accessCalendar` | `calendar:navigated`, `calendar:loaded`, `calendar:changed`, `calendar:selected`, `calendar:filtered`, `calendar:restored` |
|
|
427
|
+
| `createTimeline` | `accessTimeline` | `timeline:loaded`, `timeline:appended`, `timeline:selected`, `timeline:filtered`, `timeline:restored` |
|
|
427
428
|
| `createViews` | `accessViews` | `views:initialized`, `views:selected`, `views:saved`, `views:renamed`, `views:removed`, `views:reverted`, `views:failed` |
|
|
428
429
|
|
|
430
|
+
`createTable`, `createBrowser`, `createCalendar`, and `createTimeline` take a `refresh` beside the `fetch`: with
|
|
431
|
+
it the service has a sync, the refresh button opens the sync menu, its
|
|
432
|
+
items read in the visitor's locale (`sync.now`, `sync.off`, `sync.seconds`,
|
|
433
|
+
`sync.minutes`) with `check` after the interval the sync is on, and a poll
|
|
434
|
+
that fails is logged as a warning under the service's id. The interval a
|
|
435
|
+
visitor picks lives in the id's shared container, so it outlives the page.
|
|
436
|
+
|
|
429
437
|
Every relayed payload carries the service's `id`. `useHooks` subscribes
|
|
430
438
|
for one instance: each listener fires for events with that id only, and
|
|
431
439
|
the subscriptions leave with the calling scope, so call it in setup.
|
|
@@ -444,10 +452,12 @@ Each relay is also logged at `debug` under the service's id (see
|
|
|
444
452
|
|
|
445
453
|
`createViews` builds saved views over another service. Its composable
|
|
446
454
|
takes what the views are over, anything with a `snapshot` and a `restore`,
|
|
447
|
-
which a table, a browser, and a
|
|
448
|
-
`TABLE_VIEW_SCHEMA`, `BROWSER_VIEW_SCHEMA`,
|
|
449
|
-
the Zod schemas of what each yields, and
|
|
450
|
-
`CalendarView` their types.
|
|
455
|
+
which a table, a browser, a calendar, and a timeline service each have;
|
|
456
|
+
`TABLE_VIEW_SCHEMA`, `BROWSER_VIEW_SCHEMA`, `CALENDAR_VIEW_SCHEMA`, and
|
|
457
|
+
`TIMELINE_VIEW_SCHEMA` are the Zod schemas of what each yields, and
|
|
458
|
+
`TableView`, `BrowserView`, `CalendarView`, and `TimelineView` their types. Each carries the sync's `interval`, off where
|
|
459
|
+
a view stored before it names none, so a saved view keeps itself up to
|
|
460
|
+
date as it was saved to. Without a `load`, a `save`, and
|
|
451
461
|
a `remove` the views live in the store alone.
|
|
452
462
|
|
|
453
463
|
```ts
|
|
@@ -595,7 +605,7 @@ app/
|
|
|
595
605
|
components/ — the wrapped vue components: wrap(<Core>, { pt, slots }), NuxtLink under link parts, icons in the slots, the layer's components under nested parts; icon.ts is the icon glue they share
|
|
596
606
|
error.vue — the error page
|
|
597
607
|
app.d.ts — RuntimeNuxtHooks augmentation for the relayed events; the vue item types and the headless action descriptors widened with `icon`
|
|
598
|
-
constants/ — error page status codes, log levels, the editor's and the calendar's tools' icons and text, the table's search key, the schemas of a table's, a browser's and a
|
|
608
|
+
constants/ — error page status codes, log levels, the editor's and the calendar's tools' icons and text, the table's search key, the schemas of a table's, a browser's, a calendar's and a timeline's saved view
|
|
599
609
|
assets/css/ — reset.css, loaded by the layer config
|
|
600
610
|
composables/ — useAppError, useFocusKey, useHooks, useLogger, useNotifications, useRequest, useLazyRequest
|
|
601
611
|
factories/ — create<Name>(id, options) → use<Name>(): Service
|
package/app/app.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { FormHooks } from "./types/form";
|
|
|
6
6
|
import type { Logger } from "./types/log";
|
|
7
7
|
import type { IconAlias } from "./types/icon";
|
|
8
8
|
import type { TableHooks } from "./types/table";
|
|
9
|
+
import type { TimelineHooks } from "./types/timeline";
|
|
9
10
|
import type { ViewsHooks } from "./types/views";
|
|
10
11
|
import type { AppMessage } from "./types/text";
|
|
11
12
|
import type { CellData, RowData, TableFeatures } from "@tanstack/table-core";
|
|
@@ -121,6 +122,7 @@ declare module "#app" {
|
|
|
121
122
|
EditorHooks,
|
|
122
123
|
FormHooks,
|
|
123
124
|
TableHooks,
|
|
125
|
+
TimelineHooks,
|
|
124
126
|
ViewsHooks {}
|
|
125
127
|
}
|
|
126
128
|
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
// checkboxes. Its Fab slots draw the `sort`, `refresh` and `actions`
|
|
8
8
|
// icons: the sort trigger draws `sort` until the files sort by a column,
|
|
9
9
|
// then `sort-asc` or `sort-desc`, which the column's item in the menu draws
|
|
10
|
-
// too.
|
|
10
|
+
// too. Where the browser has a sync, the menu behind the refresh is the
|
|
11
|
+
// layer's Menu, its items in the visitor's locale and `check` after the
|
|
12
|
+
// interval the sync is on. The root crumb draws `folder-open`, a crumb below it its own `icon`,
|
|
11
13
|
// a folder draws `folder` before its name, a bulk action its own `icon`.
|
|
12
14
|
// Its own text — the search's placeholder, the sort, refresh and actions
|
|
13
15
|
// labels, the listing's counts, the empty states, the clear button — reads
|
|
@@ -36,6 +38,7 @@ import Menu from "./menu";
|
|
|
36
38
|
import TableSearch from "./table-search";
|
|
37
39
|
import { icon, iconOf, iconPart } from "./icon";
|
|
38
40
|
import { cellSlots, folderCellSlots } from "./cell";
|
|
41
|
+
import { syncLabel, syncMark } from "./sync";
|
|
39
42
|
import { text, textSlot } from "./text";
|
|
40
43
|
|
|
41
44
|
// The direction the files sort in, as its icon.
|
|
@@ -57,6 +60,7 @@ export default wrap(Core, {
|
|
|
57
60
|
selectAllCheckbox: { as: Checkbox },
|
|
58
61
|
}),
|
|
59
62
|
refresh: { label: text("browser.refresh"), ...pt?.refresh },
|
|
63
|
+
syncMenu: { as: Menu, ...pt?.syncMenu },
|
|
60
64
|
files: layer<BrowserFilesPassthrough<unknown>>(pt?.files, {
|
|
61
65
|
link: () => ({ as: NuxtLink }),
|
|
62
66
|
rowCheckbox: { as: Checkbox },
|
|
@@ -92,6 +96,8 @@ export default wrap(Core, {
|
|
|
92
96
|
}),
|
|
93
97
|
),
|
|
94
98
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
99
|
+
syncLabel: ({ item }) => syncLabel(item),
|
|
100
|
+
syncAppend: ({ browser, item }) => syncMark(browser.sync, item),
|
|
95
101
|
actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
|
|
96
102
|
folderActions: ({ settings }) =>
|
|
97
103
|
iconPart(settings.actionsTrigger, "actions"),
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// keep their names as text. Its search, where the service is searchable,
|
|
5
5
|
// is the layer's TableSearch (the Autocomplete with the `magic` icon, the
|
|
6
6
|
// search key, and that key focusing it), under the visitor's placeholder,
|
|
7
|
-
// and its refresh draws the `refresh` icon under the visitor's label
|
|
7
|
+
// and its refresh draws the `refresh` icon under the visitor's label;
|
|
8
|
+
// where the calendar has a sync, the menu behind it is the layer's Menu,
|
|
9
|
+
// its items in the visitor's locale and `check` after the interval the
|
|
10
|
+
// sync is on. An
|
|
8
11
|
// untitled occurrence and the empty agenda read in the visitor's locale
|
|
9
12
|
// too.
|
|
10
13
|
import type {
|
|
@@ -18,7 +21,9 @@ import Core from "@zoobzio/vue/components/calendar.vue";
|
|
|
18
21
|
import { h } from "vue";
|
|
19
22
|
import { layer } from "@zoobzio/vue/utils/passthrough";
|
|
20
23
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
24
|
+
import Menu from "./menu";
|
|
21
25
|
import TableSearch from "./table-search";
|
|
26
|
+
import { syncLabel, syncMark } from "./sync";
|
|
22
27
|
import { iconOf, iconPart } from "./icon";
|
|
23
28
|
import { text, textIn, textSlot } from "./text";
|
|
24
29
|
import { toolIcon, toolText } from "../utils/calendar";
|
|
@@ -49,10 +54,13 @@ export default wrap(Core, {
|
|
|
49
54
|
layer<CalendarPassthrough>(pt, {
|
|
50
55
|
search: { as: TableSearch, placeholder: text("calendar.search") },
|
|
51
56
|
refresh: { label: text("calendar.refresh") },
|
|
57
|
+
syncMenu: { as: Menu },
|
|
52
58
|
tool: toolLayer,
|
|
53
59
|
}),
|
|
54
60
|
slots: {
|
|
55
61
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
62
|
+
syncLabel: ({ item }) => syncLabel(item),
|
|
63
|
+
syncAppend: ({ calendar, item }) => syncMark(calendar.sync, item),
|
|
56
64
|
toolLabel: ({ tool }) => toolLabel(tool),
|
|
57
65
|
// A title is the entry's own text, never a message; only the name of
|
|
58
66
|
// an entry without one is the layer's.
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// The tool glue the editor and rich text wrappers share: the layer under
|
|
2
2
|
// `pt.tool` that names each button in the visitor's locale, the label slot
|
|
3
|
-
// that draws its icon,
|
|
4
|
-
// the
|
|
3
|
+
// that draws its icon, the block type dropdown's trigger and items in the
|
|
4
|
+
// visitor's locale, and the labels of a prompt's fields and buttons. It sits with the wrappers, as `icon.ts` and
|
|
5
5
|
// `text.ts` do, because it renders through them; `utils/editor` holds the
|
|
6
6
|
// lookups alone, which the factories reach without a Nuxt app.
|
|
7
7
|
import type {
|
|
8
8
|
EditorBlock,
|
|
9
|
+
EditorField,
|
|
9
10
|
EditorTool,
|
|
10
11
|
} from "@zoobzio/vue/types/components/editor";
|
|
11
12
|
import type { VNode } from "vue";
|
|
12
13
|
|
|
13
14
|
import { icon, iconOf } from "./icon";
|
|
14
15
|
import { text, textIn, textSlot } from "./text";
|
|
15
|
-
import { toolIcon, toolText } from "../utils/editor";
|
|
16
|
+
import { fieldText, toolIcon, toolText } from "../utils/editor";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* The label of a tool as the visitor reads it: the contract's message for
|
|
@@ -61,3 +62,19 @@ export const blockAppend = (): VNode[] => [icon("expand")];
|
|
|
61
62
|
|
|
62
63
|
/** One entry of the block type dropdown, by name. */
|
|
63
64
|
export const blockItemLabel = (item: EditorBlock): VNode[] => blockText(item);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The label of a prompt's field, in a span as the editor's own renders it:
|
|
68
|
+
* the contract's message for the fields the layer names, the field's own
|
|
69
|
+
* label otherwise.
|
|
70
|
+
*/
|
|
71
|
+
export const fieldLabel = (field: EditorField): VNode[] =>
|
|
72
|
+
textIn("span", "f-span", fieldText(field.key) ?? field.label);
|
|
73
|
+
|
|
74
|
+
/** The text of the button that applies a prompt. */
|
|
75
|
+
export const submitLabel = (): VNode[] =>
|
|
76
|
+
textIn("span", "f-span", "editor.apply");
|
|
77
|
+
|
|
78
|
+
/** The text of the button that removes what a prompt set. */
|
|
79
|
+
export const clearLabel = (): VNode[] =>
|
|
80
|
+
textIn("span", "f-span", "editor.remove");
|
package/app/components/editor.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// accessible name and its tooltip. A tool the layer has no icon for keeps
|
|
4
4
|
// its label as text. The block type dropdown reads its trigger and its
|
|
5
5
|
// entries in the visitor's locale, with the `expand` icon after the
|
|
6
|
-
// trigger's text
|
|
6
|
+
// trigger's text, and the prompts of the link and the image read theirs
|
|
7
|
+
// there too.
|
|
7
8
|
import type { EditorPassthrough } from "@zoobzio/vue/types/components/editor";
|
|
8
9
|
|
|
9
10
|
import Core from "@zoobzio/vue/components/editor.vue";
|
|
@@ -14,6 +15,9 @@ import {
|
|
|
14
15
|
blockAppend,
|
|
15
16
|
blockItemLabel,
|
|
16
17
|
blockLabel,
|
|
18
|
+
clearLabel,
|
|
19
|
+
fieldLabel,
|
|
20
|
+
submitLabel,
|
|
17
21
|
toolLabel,
|
|
18
22
|
toolLayer,
|
|
19
23
|
} from "./editor-tool";
|
|
@@ -25,5 +29,8 @@ export default wrap(Core, {
|
|
|
25
29
|
blockLabel: ({ block }) => blockLabel(block),
|
|
26
30
|
blockAppend: () => blockAppend(),
|
|
27
31
|
blockItemLabel: ({ item }) => blockItemLabel(item),
|
|
32
|
+
fieldLabel: ({ field }) => fieldLabel(field),
|
|
33
|
+
submitLabel: () => submitLabel(),
|
|
34
|
+
clearLabel: () => clearLabel(),
|
|
28
35
|
},
|
|
29
36
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The vue rich text as an icon toolbar, as the editor: each tool draws its
|
|
2
2
|
// icon in place of its label, the label, in the visitor's locale, stays
|
|
3
3
|
// the button's accessible name and its tooltip, and the block type
|
|
4
|
-
// dropdown
|
|
4
|
+
// dropdown and the prompts read in the visitor's locale.
|
|
5
5
|
import type { RichTextPassthrough } from "@zoobzio/vue/types/components/rich-text";
|
|
6
6
|
|
|
7
7
|
import Core from "@zoobzio/vue/components/rich-text.vue";
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
blockAppend,
|
|
13
13
|
blockItemLabel,
|
|
14
14
|
blockLabel,
|
|
15
|
+
clearLabel,
|
|
16
|
+
fieldLabel,
|
|
17
|
+
submitLabel,
|
|
15
18
|
toolLabel,
|
|
16
19
|
toolLayer,
|
|
17
20
|
} from "./editor-tool";
|
|
@@ -23,5 +26,8 @@ export default wrap(Core, {
|
|
|
23
26
|
blockLabel: ({ block }) => blockLabel(block),
|
|
24
27
|
blockAppend: () => blockAppend(),
|
|
25
28
|
blockItemLabel: ({ item }) => blockItemLabel(item),
|
|
29
|
+
fieldLabel: ({ field }) => fieldLabel(field),
|
|
30
|
+
submitLabel: () => submitLabel(),
|
|
31
|
+
clearLabel: () => clearLabel(),
|
|
26
32
|
},
|
|
27
33
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The sync glue of the wrappers: the items of the menu behind a table's or
|
|
2
|
+
// a browser's refresh, where it has a sync, in the visitor's locale, and
|
|
3
|
+
// the `check` icon after the item of the interval the sync is on. It sits
|
|
4
|
+
// with the wrappers because it resolves text and names `Icon`, which only
|
|
5
|
+
// they may.
|
|
6
|
+
import type { SyncItem } from "@zoobzio/vue/types/components/sync";
|
|
7
|
+
import type { Service } from "@zoobzio/sync";
|
|
8
|
+
import type { VNode } from "vue";
|
|
9
|
+
|
|
10
|
+
import { SYNC_NOW_KEY, SYNC_OFF_KEY } from "@zoobzio/vue/constants/sync";
|
|
11
|
+
import { intervalParts, isSyncCurrent } from "@zoobzio/vue/utils/sync";
|
|
12
|
+
import { h } from "vue";
|
|
13
|
+
import { icon } from "./icon";
|
|
14
|
+
import { text } from "./text";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The text of a sync menu's item: the refresh, off, or the interval the
|
|
18
|
+
* item carries, in seconds or in whole minutes.
|
|
19
|
+
*/
|
|
20
|
+
const syncText = (item: SyncItem): string => {
|
|
21
|
+
if (item.key === SYNC_NOW_KEY) return text("sync.now");
|
|
22
|
+
if (item.key === SYNC_OFF_KEY) return text("sync.off");
|
|
23
|
+
if (item.interval === undefined) return text(item.label);
|
|
24
|
+
const { unit, count } = intervalParts(item.interval);
|
|
25
|
+
return unit === "minutes"
|
|
26
|
+
? text("sync.minutes", { count })
|
|
27
|
+
: text("sync.seconds", { count });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** An item's label, as the default of a `syncLabel` slot. */
|
|
31
|
+
export const syncLabel = (item: SyncItem): VNode[] => [
|
|
32
|
+
h("span", { class: "f-span" }, syncText(item)),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The mark of the interval the sync is on, as the default of a
|
|
37
|
+
* `syncAppend` slot: nothing after any other item.
|
|
38
|
+
*/
|
|
39
|
+
export const syncMark = (sync: Service | undefined, item: SyncItem): VNode[] =>
|
|
40
|
+
isSyncCurrent(sync, item) ? [icon("check")] : [];
|
package/app/components/table.ts
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// Autocomplete with the `magic` icon, the `/` key hint, and the `/` key
|
|
6
6
|
// focusing it) as the search, the layer's Scroller around the `table`
|
|
7
7
|
// element, and the layer's Pagination.
|
|
8
|
-
// Its Fab slots draw the `refresh`, `columns`, and `actions` icons;
|
|
8
|
+
// Its Fab slots draw the `refresh`, `columns`, and `actions` icons; where
|
|
9
|
+
// the table has a sync, the menu behind the refresh is the layer's Menu,
|
|
10
|
+
// its items in the visitor's locale and `check` after the interval the
|
|
11
|
+
// sync is on; the
|
|
9
12
|
// head draws `drag` on each handle, a column's own `icon` before its
|
|
10
13
|
// header, and `sort-asc` or `sort-desc` after a sorted header; a column's
|
|
11
14
|
// pin menu is the layer's Menu, opened by `pin` (`unpin` on a pinned
|
|
@@ -38,6 +41,7 @@ import Scroller from "./scroller";
|
|
|
38
41
|
import TableSearch from "./table-search";
|
|
39
42
|
import { icon, iconOf, iconPart } from "./icon";
|
|
40
43
|
import { cellSlots } from "./cell";
|
|
44
|
+
import { syncLabel, syncMark } from "./sync";
|
|
41
45
|
import { text, textSlot } from "./text";
|
|
42
46
|
|
|
43
47
|
/** The icon of each item of a column's pin menu. */
|
|
@@ -56,6 +60,7 @@ export default wrap(Core, {
|
|
|
56
60
|
...pt?.search,
|
|
57
61
|
},
|
|
58
62
|
refresh: { label: text("table.refresh"), ...pt?.refresh },
|
|
63
|
+
syncMenu: { as: Menu, ...pt?.syncMenu },
|
|
59
64
|
pagination: { as: Pagination, ...pt?.pagination },
|
|
60
65
|
scroller: { as: Scroller, ...pt?.scroller },
|
|
61
66
|
head: layer<TableHeadPassthrough<RowData>>(pt?.head, {
|
|
@@ -96,6 +101,8 @@ export default wrap(Core, {
|
|
|
96
101
|
slots: {
|
|
97
102
|
...cellSlots<TableCellContext<RowData>>(({ table }) => table),
|
|
98
103
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
104
|
+
syncLabel: ({ item }) => syncLabel(item),
|
|
105
|
+
syncAppend: ({ table, item }) => syncMark(table.sync, item),
|
|
99
106
|
columns: ({ settings }) => iconPart(settings.trigger, "columns"),
|
|
100
107
|
actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
|
|
101
108
|
dragPrepend: () => [icon("drag")],
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The vue timeline in the visitor's locale: its search, where the service
|
|
2
|
+
// is searchable, is the layer's TableSearch, under the visitor's
|
|
3
|
+
// placeholder, and its refresh draws the `refresh` icon under the
|
|
4
|
+
// visitor's label; where the timeline has a sync, the menu behind it is
|
|
5
|
+
// the layer's Menu, its items in the visitor's locale and `check` after
|
|
6
|
+
// the interval the sync is on. The button that loads the next batch and
|
|
7
|
+
// the text of a timeline with no record read in the visitor's locale too.
|
|
8
|
+
// A record's name is the record's own text, never a message.
|
|
9
|
+
import type { TimelinePassthrough } from "@zoobzio/vue/types/components/timeline";
|
|
10
|
+
import type { RecordData } from "@zoobzio/timeline";
|
|
11
|
+
|
|
12
|
+
import Core from "@zoobzio/vue/components/timeline.vue";
|
|
13
|
+
|
|
14
|
+
import { layer } from "@zoobzio/vue/utils/passthrough";
|
|
15
|
+
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
16
|
+
import Menu from "./menu";
|
|
17
|
+
import TableSearch from "./table-search";
|
|
18
|
+
import { syncLabel, syncMark } from "./sync";
|
|
19
|
+
import { iconPart } from "./icon";
|
|
20
|
+
import { text, textSlot } from "./text";
|
|
21
|
+
|
|
22
|
+
export default wrap(Core, {
|
|
23
|
+
pt: (pt) =>
|
|
24
|
+
layer<TimelinePassthrough<RecordData>>(pt, {
|
|
25
|
+
search: { as: TableSearch, placeholder: text("timeline.search") },
|
|
26
|
+
refresh: { label: text("timeline.refresh") },
|
|
27
|
+
syncMenu: { as: Menu },
|
|
28
|
+
more: { label: text("timeline.more") },
|
|
29
|
+
}),
|
|
30
|
+
slots: {
|
|
31
|
+
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
32
|
+
syncLabel: ({ item }) => syncLabel(item),
|
|
33
|
+
syncAppend: ({ timeline, item }) => syncMark(timeline.sync, item),
|
|
34
|
+
empty: () => textSlot("timeline.empty"),
|
|
35
|
+
},
|
|
36
|
+
});
|
package/app/constants/editor.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { IconAlias } from "../types/icon";
|
|
|
2
2
|
import type { AppMessage } from "../types/text";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The icon of each editor tool, by the tool's key: the marks, the
|
|
6
|
-
* and history. The headings have none: they are the entries of the block
|
|
5
|
+
* The icon of each editor tool, by the tool's key: the marks, the link,
|
|
6
|
+
* the blocks, the image, and history. The headings have none: they are the entries of the block
|
|
7
7
|
* type dropdown, read by name. The editor and rich text wrappers draw
|
|
8
8
|
* these as each button's content, in place of the label text.
|
|
9
9
|
*/
|
|
@@ -13,18 +13,20 @@ export const EDITOR_TOOL_ICONS: Readonly<Record<string, IconAlias>> = {
|
|
|
13
13
|
underline: "underline",
|
|
14
14
|
strike: "strike",
|
|
15
15
|
code: "code",
|
|
16
|
+
link: "link",
|
|
16
17
|
bulletList: "bullet-list",
|
|
17
18
|
orderedList: "ordered-list",
|
|
18
19
|
blockquote: "blockquote",
|
|
19
20
|
codeBlock: "code-block",
|
|
20
21
|
horizontalRule: "rule",
|
|
22
|
+
image: "image",
|
|
21
23
|
undo: "undo",
|
|
22
24
|
redo: "redo",
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* The message of each editor tool's label, by the tool's key: the marks,
|
|
27
|
-
* the blocks, and history, and `paragraph`, the block type dropdown's
|
|
29
|
+
* the link, the blocks, the image, and history, and `paragraph`, the block type dropdown's
|
|
28
30
|
* entry that is no tool. A heading tool is not here: its message takes
|
|
29
31
|
* the level its key carries, which `toolText` reads.
|
|
30
32
|
*/
|
|
@@ -35,11 +37,24 @@ export const EDITOR_TOOL_TEXT: Readonly<Record<string, AppMessage>> = {
|
|
|
35
37
|
underline: "editor.underline",
|
|
36
38
|
strike: "editor.strike",
|
|
37
39
|
code: "editor.code",
|
|
40
|
+
link: "editor.link",
|
|
38
41
|
bulletList: "editor.bulletList",
|
|
39
42
|
orderedList: "editor.orderedList",
|
|
40
43
|
blockquote: "editor.blockquote",
|
|
41
44
|
codeBlock: "editor.codeBlock",
|
|
42
45
|
horizontalRule: "editor.rule",
|
|
46
|
+
image: "editor.image",
|
|
43
47
|
undo: "editor.undo",
|
|
44
48
|
redo: "editor.redo",
|
|
45
49
|
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The message of each field of a prompt, by the field's key: the address
|
|
53
|
+
* of a link (`href`) and of an image (`src`), and an image's alternative
|
|
54
|
+
* text.
|
|
55
|
+
*/
|
|
56
|
+
export const EDITOR_FIELD_TEXT: Readonly<Record<string, AppMessage>> = {
|
|
57
|
+
href: "editor.url",
|
|
58
|
+
src: "editor.url",
|
|
59
|
+
alt: "editor.alt",
|
|
60
|
+
};
|
package/app/constants/views.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The interval of the sync, in milliseconds: off, zero, where a view was
|
|
5
|
+
* stored before it carried one.
|
|
6
|
+
*/
|
|
7
|
+
const interval = z.number().int().nonnegative().default(0);
|
|
8
|
+
|
|
3
9
|
const clause = z.discriminatedUnion("kind", [
|
|
4
10
|
z.object({
|
|
5
11
|
kind: z.literal("literal"),
|
|
@@ -50,17 +56,30 @@ export const TABLE_VIEW_SCHEMA = z.preprocess(
|
|
|
50
56
|
columnSizing: z.record(z.string(), z.number()).default({}),
|
|
51
57
|
pageSize: z.number().int().positive().default(10),
|
|
52
58
|
clauses: z.array(clause).default([]),
|
|
59
|
+
interval,
|
|
53
60
|
}),
|
|
54
61
|
);
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* The schema of a calendar's saved view: what the calendar's `snapshot`
|
|
58
|
-
* yields and its `restore` takes. The view alone,
|
|
65
|
+
* yields and its `restore` takes. The view alone, the search, and the
|
|
66
|
+
* sync's interval: a saved
|
|
59
67
|
* view opens on the day the calendar stands on.
|
|
60
68
|
*/
|
|
61
69
|
export const CALENDAR_VIEW_SCHEMA = z.object({
|
|
62
70
|
view: z.enum(["month", "week", "day", "agenda"]).default("month"),
|
|
63
71
|
clauses: z.array(clause).default([]),
|
|
72
|
+
interval,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The schema of a timeline's saved view: what the timeline's `snapshot`
|
|
77
|
+
* yields and its `restore` takes. The search and the sync's interval: a
|
|
78
|
+
* saved view opens on the latest records, however far down it was read.
|
|
79
|
+
*/
|
|
80
|
+
export const TIMELINE_VIEW_SCHEMA = z.object({
|
|
81
|
+
clauses: z.array(clause).default([]),
|
|
82
|
+
interval,
|
|
64
83
|
});
|
|
65
84
|
|
|
66
85
|
/**
|
|
@@ -73,5 +92,6 @@ export const BROWSER_VIEW_SCHEMA = z.preprocess(
|
|
|
73
92
|
sortField: z.string().nullable().default(null),
|
|
74
93
|
sortDirection: z.enum(["asc", "desc"]).default("asc"),
|
|
75
94
|
clauses: z.array(clause).default([]),
|
|
95
|
+
interval,
|
|
76
96
|
}),
|
|
77
97
|
);
|
package/app/factories/browser.ts
CHANGED
|
@@ -21,7 +21,9 @@ import { resolveTexts } from "../utils/text";
|
|
|
21
21
|
* as the service is built. A config that names no `rootLabel` takes the
|
|
22
22
|
* contract's `browser.root`, and one that names no `literals` the query's
|
|
23
23
|
* text literal under `browser.text`, so the root crumb and the search's
|
|
24
|
-
* leading option read in the visitor's locale.
|
|
24
|
+
* leading option read in the visitor's locale. With a `refresh` among the
|
|
25
|
+
* options the browser has a sync, whose failed polls are logged as
|
|
26
|
+
* warnings. The machine itself is
|
|
25
27
|
* `@zoobzio/browser`; the Vue browser renders it through its `service`
|
|
26
28
|
* prop.
|
|
27
29
|
*/
|
|
@@ -29,8 +31,15 @@ export const createBrowser = <T>(
|
|
|
29
31
|
id: string,
|
|
30
32
|
options: BrowserOptions<T>,
|
|
31
33
|
): UseBrowser<T> => {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
+
const {
|
|
35
|
+
fetch,
|
|
36
|
+
refresh,
|
|
37
|
+
actions,
|
|
38
|
+
folderActions,
|
|
39
|
+
bulkActions,
|
|
40
|
+
initial,
|
|
41
|
+
...rest
|
|
42
|
+
} = options;
|
|
34
43
|
const files = split(actions);
|
|
35
44
|
const folders = split(folderActions);
|
|
36
45
|
const bulk = split(bulkActions);
|
|
@@ -46,6 +55,7 @@ export const createBrowser = <T>(
|
|
|
46
55
|
};
|
|
47
56
|
const wiring: Actions<T> = {
|
|
48
57
|
fetch,
|
|
58
|
+
...(refresh && { refresh }),
|
|
49
59
|
actions: files.handlers,
|
|
50
60
|
folderActions: folders.handlers,
|
|
51
61
|
bulkActions: bulk.handlers,
|
|
@@ -54,7 +64,7 @@ export const createBrowser = <T>(
|
|
|
54
64
|
const nuxt = useNuxtApp();
|
|
55
65
|
const log = nuxt.$logger(id);
|
|
56
66
|
const resolved = resolveTexts(nuxt.$prosary, config);
|
|
57
|
-
const state = accessBrowser<T>(id, initial);
|
|
67
|
+
const state = accessBrowser<T>(id, initial, config);
|
|
58
68
|
const service = new BrowserService(id, resolved, state, wiring);
|
|
59
69
|
service.on("updated", (event) => {
|
|
60
70
|
log.debug("Browser updated", event);
|
|
@@ -72,6 +82,11 @@ export const createBrowser = <T>(
|
|
|
72
82
|
log.debug("Browser restored", event);
|
|
73
83
|
nuxt.callHook("browser:restored", event);
|
|
74
84
|
});
|
|
85
|
+
// A poll that fails is no one's to catch: it is logged, and the sync
|
|
86
|
+
// keeps its pace.
|
|
87
|
+
service.sync?.on("failed", ({ error }) => {
|
|
88
|
+
log.warn("Browser sync failed", { error });
|
|
89
|
+
});
|
|
75
90
|
return service;
|
|
76
91
|
};
|
|
77
92
|
};
|
|
@@ -19,7 +19,9 @@ import { resolveTexts } from "../utils/text";
|
|
|
19
19
|
* key of the app's contract reaches the machine, and the search that
|
|
20
20
|
* matches a typed prefix against it, as the visitor reads it. A config
|
|
21
21
|
* that searches and names no literals takes the query's text literal
|
|
22
|
-
* under the contract's `calendar.text`.
|
|
22
|
+
* under the contract's `calendar.text`. With a `refresh` among the options
|
|
23
|
+
* the calendar has a sync, whose failed polls are logged as warnings. The
|
|
24
|
+
* machine itself is
|
|
23
25
|
* `@zoobzio/calendar`; the Vue calendar renders it through its `service`
|
|
24
26
|
* prop.
|
|
25
27
|
*/
|
|
@@ -27,8 +29,17 @@ export const createCalendar = <I, O>(
|
|
|
27
29
|
id: string,
|
|
28
30
|
options: CalendarOptions<I, O>,
|
|
29
31
|
): UseCalendar<I, O> => {
|
|
30
|
-
const { read, write, fetch, save, now, uid, initial, ...config } =
|
|
31
|
-
|
|
32
|
+
const { read, write, fetch, refresh, save, now, uid, initial, ...config } =
|
|
33
|
+
options;
|
|
34
|
+
const wiring: Actions<I, O> = {
|
|
35
|
+
read,
|
|
36
|
+
write,
|
|
37
|
+
fetch,
|
|
38
|
+
...(refresh && { refresh }),
|
|
39
|
+
save,
|
|
40
|
+
now,
|
|
41
|
+
uid,
|
|
42
|
+
};
|
|
32
43
|
// A calendar that names neither fields nor literals renders no search,
|
|
33
44
|
// and naming the literal here would say it does.
|
|
34
45
|
const searches = config.searchable ?? config.fields !== undefined;
|
|
@@ -71,6 +82,11 @@ export const createCalendar = <I, O>(
|
|
|
71
82
|
log.debug("Calendar restored", event);
|
|
72
83
|
nuxt.callHook("calendar:restored", event);
|
|
73
84
|
});
|
|
85
|
+
// A poll that fails is no one's to catch: it is logged, and the sync
|
|
86
|
+
// keeps its pace.
|
|
87
|
+
service.sync?.on("failed", ({ error }) => {
|
|
88
|
+
log.warn("Calendar sync failed", { error });
|
|
89
|
+
});
|
|
74
90
|
return service;
|
|
75
91
|
};
|
|
76
92
|
};
|
package/app/factories/table.ts
CHANGED
|
@@ -25,14 +25,15 @@ import { resolveTexts } from "../utils/text";
|
|
|
25
25
|
* the search's placeholder does. The composable takes the permissions of
|
|
26
26
|
* the visitor it is called for, as a record, a ref, or a getter: they
|
|
27
27
|
* stand over the options' `permissions`, key by key, and are read on every
|
|
28
|
-
* check.
|
|
28
|
+
* check. With a `refresh` among the options the table has a sync, whose
|
|
29
|
+
* failed polls are logged as warnings. The machine itself is `@zoobzio/table`;
|
|
29
30
|
* the Vue table renders it through its `service` prop.
|
|
30
31
|
*/
|
|
31
32
|
export const createTable = <T extends RowData>(
|
|
32
33
|
id: string,
|
|
33
34
|
options: TableOptions<T>,
|
|
34
35
|
): UseTable<T> => {
|
|
35
|
-
const { fetch, actions, bulkActions, ...rest } = options;
|
|
36
|
+
const { fetch, refresh, actions, bulkActions, ...rest } = options;
|
|
36
37
|
const rows = split(actions);
|
|
37
38
|
const bulk = split(bulkActions);
|
|
38
39
|
const config: Config<T> = {
|
|
@@ -45,6 +46,7 @@ export const createTable = <T extends RowData>(
|
|
|
45
46
|
};
|
|
46
47
|
const wiring: Actions<T> = {
|
|
47
48
|
fetch,
|
|
49
|
+
...(refresh && { refresh }),
|
|
48
50
|
actions: rows.handlers,
|
|
49
51
|
bulkActions: bulk.handlers,
|
|
50
52
|
};
|
|
@@ -72,6 +74,11 @@ export const createTable = <T extends RowData>(
|
|
|
72
74
|
log.debug("Table restored", event);
|
|
73
75
|
nuxt.callHook("table:restored", event);
|
|
74
76
|
});
|
|
77
|
+
// A poll that fails is no one's to catch: it is logged, and the sync
|
|
78
|
+
// keeps its pace.
|
|
79
|
+
service.sync?.on("failed", ({ error }) => {
|
|
80
|
+
log.warn("Table sync failed", { error });
|
|
81
|
+
});
|
|
75
82
|
return service;
|
|
76
83
|
};
|
|
77
84
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TimelineOptions, UseTimeline } from "../types/timeline";
|
|
2
|
+
import type { Actions, Config, RecordData, Service } from "@zoobzio/timeline";
|
|
3
|
+
|
|
4
|
+
import { useNuxtApp } from "#app";
|
|
5
|
+
import { TimelineService } from "@zoobzio/timeline";
|
|
6
|
+
import { QUERY_TEXT_KEY, QUERY_TEXT_LITERAL } from "@zoobzio/query";
|
|
7
|
+
import { accessTimeline } from "../stores/timeline";
|
|
8
|
+
import { resolveTexts } from "../utils/text";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds the id-scoped composable of a timeline. Call it at module scope:
|
|
12
|
+
* the options split once into the headless config and the actions (the
|
|
13
|
+
* fetch and the refresh), and `id` keys everything that follows. Each
|
|
14
|
+
* call of the composable, in setup, builds a service over the id's shared
|
|
15
|
+
* store and relays its domain events onto the app logger and the Nuxt
|
|
16
|
+
* hook bus under the `timeline:` prefix. Every text of the config, the
|
|
17
|
+
* labels of the query's fields and literals, resolves through the app's
|
|
18
|
+
* prosary service as the service is built, so a label that is a key of
|
|
19
|
+
* the app's contract reaches the machine as the visitor reads it. A
|
|
20
|
+
* config that searches and names no literals takes the query's text
|
|
21
|
+
* literal under the contract's `timeline.text`. With a `refresh` among
|
|
22
|
+
* the options the timeline has a sync, whose failed polls are logged as
|
|
23
|
+
* warnings. The machine itself is `@zoobzio/timeline`; the Vue timeline
|
|
24
|
+
* renders it through its `service` prop.
|
|
25
|
+
*/
|
|
26
|
+
export const createTimeline = <T extends RecordData>(
|
|
27
|
+
id: string,
|
|
28
|
+
options: TimelineOptions<T>,
|
|
29
|
+
): UseTimeline<T> => {
|
|
30
|
+
const { fetch, refresh, now, initial, ...config } = options;
|
|
31
|
+
const wiring: Actions<T> = {
|
|
32
|
+
fetch,
|
|
33
|
+
...(refresh && { refresh }),
|
|
34
|
+
now,
|
|
35
|
+
};
|
|
36
|
+
// A timeline that names neither fields nor literals renders no search,
|
|
37
|
+
// and naming the literal here would say it does.
|
|
38
|
+
const searches = config.searchable ?? config.fields !== undefined;
|
|
39
|
+
const settings: Config<T> = {
|
|
40
|
+
...config,
|
|
41
|
+
...(searches &&
|
|
42
|
+
config.literals === undefined && {
|
|
43
|
+
literals: {
|
|
44
|
+
[QUERY_TEXT_KEY]: { ...QUERY_TEXT_LITERAL, label: "timeline.text" },
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
return (): Service<T> => {
|
|
49
|
+
const nuxt = useNuxtApp();
|
|
50
|
+
const log = nuxt.$logger(id);
|
|
51
|
+
const resolved = resolveTexts(nuxt.$prosary, settings);
|
|
52
|
+
const state = accessTimeline(id, resolved, initial);
|
|
53
|
+
const service = new TimelineService<T>(id, resolved, state, wiring);
|
|
54
|
+
service.on("loaded", (event) => {
|
|
55
|
+
log.debug("Timeline loaded", event);
|
|
56
|
+
nuxt.callHook("timeline:loaded", event);
|
|
57
|
+
});
|
|
58
|
+
service.on("appended", (event) => {
|
|
59
|
+
log.debug("Timeline appended", event);
|
|
60
|
+
nuxt.callHook("timeline:appended", event);
|
|
61
|
+
});
|
|
62
|
+
service.on("selected", (event) => {
|
|
63
|
+
log.debug("Timeline selected", event);
|
|
64
|
+
nuxt.callHook("timeline:selected", event);
|
|
65
|
+
});
|
|
66
|
+
service.on("filtered", (event) => {
|
|
67
|
+
log.debug("Timeline filtered", event);
|
|
68
|
+
nuxt.callHook("timeline:filtered", event);
|
|
69
|
+
});
|
|
70
|
+
service.on("restored", (event) => {
|
|
71
|
+
log.debug("Timeline restored", event);
|
|
72
|
+
nuxt.callHook("timeline:restored", event);
|
|
73
|
+
});
|
|
74
|
+
// A poll that fails is no one's to catch: it is logged, and the sync
|
|
75
|
+
// keeps its pace.
|
|
76
|
+
service.sync?.on("failed", ({ error }) => {
|
|
77
|
+
log.warn("Timeline sync failed", { error });
|
|
78
|
+
});
|
|
79
|
+
return service;
|
|
80
|
+
};
|
|
81
|
+
};
|
package/app/stores/browser.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BrowserInitial } from "../types/browser";
|
|
2
|
-
import type { State } from "@zoobzio/browser";
|
|
2
|
+
import type { Config, State } from "@zoobzio/browser";
|
|
3
3
|
|
|
4
4
|
import { useState } from "#app";
|
|
5
5
|
import { createBrowserState } from "@zoobzio/browser";
|
|
@@ -11,13 +11,15 @@ import { seed } from "../utils/state";
|
|
|
11
11
|
* field writes are tracked; instances sharing an id share the container
|
|
12
12
|
* across the app, and it survives SSR hydration. No config parameter: the
|
|
13
13
|
* trail starts at the root and sorting starts unset, unless `initial` says
|
|
14
|
-
* otherwise
|
|
14
|
+
* otherwise, and the sync starts on the interval the `config`'s `sync`
|
|
15
|
+
* names. Both shape the record once, when it is first created; later
|
|
15
16
|
* calls under the same id get the record as it stands.
|
|
16
17
|
*/
|
|
17
18
|
export const accessBrowser = <T>(
|
|
18
19
|
id: string,
|
|
19
20
|
initial?: BrowserInitial<T>,
|
|
21
|
+
config?: Pick<Config<T>, "sync">,
|
|
20
22
|
): State<T> =>
|
|
21
23
|
useState<State<T>>(`browser-${id}`, () =>
|
|
22
|
-
seed(createBrowserState<T>(), initial),
|
|
24
|
+
seed(createBrowserState<T>(config), initial),
|
|
23
25
|
).value;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TimelineInitial } from "../types/timeline";
|
|
2
|
+
import type { Config, RecordData, State } from "@zoobzio/timeline";
|
|
3
|
+
|
|
4
|
+
import { useState } from "#app";
|
|
5
|
+
import { createTimelineState } from "@zoobzio/timeline";
|
|
6
|
+
import { seed } from "../utils/state";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The Nuxt backing for a timeline's state container: one `useState` record
|
|
10
|
+
* keyed `timeline-<id>`. Its value is a reactive proxy, so the service's
|
|
11
|
+
* field writes are tracked; instances sharing an id share the container
|
|
12
|
+
* across the app, and it survives SSR hydration, the records the server
|
|
13
|
+
* fetched and the cursor after them included. `config` and `initial`
|
|
14
|
+
* shape the record once, when it is first created; later calls under the
|
|
15
|
+
* same id get the record as it stands.
|
|
16
|
+
*/
|
|
17
|
+
export const accessTimeline = <T extends RecordData>(
|
|
18
|
+
id: string,
|
|
19
|
+
config: Config<T> = {},
|
|
20
|
+
initial?: TimelineInitial<T>,
|
|
21
|
+
): State<T> =>
|
|
22
|
+
useState<State<T>>(`timeline-${id}`, () =>
|
|
23
|
+
seed(createTimelineState(config), initial),
|
|
24
|
+
).value;
|
package/app/types/browser.ts
CHANGED
|
@@ -51,7 +51,8 @@ export type BrowserInitial<T> = Partial<
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* What `createBrowser` takes: the headless config with each action's
|
|
54
|
-
* handler joined to its descriptor, the fetch mechanism,
|
|
54
|
+
* handler joined to its descriptor, the fetch mechanism, the `refresh`
|
|
55
|
+
* that gives the browser its sync where there is one, and the initial
|
|
55
56
|
* state.
|
|
56
57
|
*/
|
|
57
58
|
export type BrowserOptions<T> = Omit<
|
|
@@ -59,6 +60,7 @@ export type BrowserOptions<T> = Omit<
|
|
|
59
60
|
"actions" | "folderActions" | "bulkActions"
|
|
60
61
|
> & {
|
|
61
62
|
fetch: Actions<T>["fetch"];
|
|
63
|
+
refresh?: Actions<T>["refresh"];
|
|
62
64
|
actions?: Record<string, BrowserAction<T>>;
|
|
63
65
|
folderActions?: Record<string, BrowserFolderAction<T>>;
|
|
64
66
|
bulkActions?: Record<string, BrowserBulkAction>;
|
package/app/types/table.ts
CHANGED
|
@@ -29,7 +29,8 @@ export type TableBulkAction = Bound<ActionDescriptor, BulkAction["action"]>;
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* What `createTable` takes: the headless config with each action's handler
|
|
32
|
-
* joined to its descriptor,
|
|
32
|
+
* joined to its descriptor, the fetch mechanism, and the `refresh` that
|
|
33
|
+
* gives the table its sync where there is one. The config's
|
|
33
34
|
* `initialState` and `initialClauses` are what the table starts from: they
|
|
34
35
|
* seed the `useState` record, so they must survive Nuxt's payload.
|
|
35
36
|
*/
|
|
@@ -38,6 +39,7 @@ export type TableOptions<T extends RowData> = Omit<
|
|
|
38
39
|
"actions" | "bulkActions"
|
|
39
40
|
> & {
|
|
40
41
|
fetch: Actions<T>["fetch"];
|
|
42
|
+
refresh?: Actions<T>["refresh"];
|
|
41
43
|
actions?: Record<string, TableAction<T>>;
|
|
42
44
|
bulkActions?: Record<string, TableBulkAction>;
|
|
43
45
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Hooks } from "./hooks";
|
|
2
|
+
import type {
|
|
3
|
+
Actions,
|
|
4
|
+
Config,
|
|
5
|
+
Events,
|
|
6
|
+
RecordData,
|
|
7
|
+
Service,
|
|
8
|
+
State,
|
|
9
|
+
} from "@zoobzio/timeline";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The slice of the state container a timeline may start from: the
|
|
13
|
+
* selected record, never what a fetch fills in. It seeds the `useState`
|
|
14
|
+
* record.
|
|
15
|
+
*/
|
|
16
|
+
export type TimelineInitial<T extends RecordData> = Partial<
|
|
17
|
+
Pick<State<T>, "selected">
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What `createTimeline` takes: the headless config, the actions (the
|
|
22
|
+
* fetch and the refresh), and the initial state. Config and actions share
|
|
23
|
+
* no key, so they sit side by side.
|
|
24
|
+
*/
|
|
25
|
+
export type TimelineOptions<T extends RecordData> = Config<T> &
|
|
26
|
+
Actions<T> & {
|
|
27
|
+
initial?: TimelineInitial<T>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The Nuxt hooks a timeline relays: `timeline:loaded`,
|
|
32
|
+
* `timeline:appended`, `timeline:selected`, `timeline:filtered`, and
|
|
33
|
+
* `timeline:restored`, each carrying the service's payload with its
|
|
34
|
+
* scoping `id`.
|
|
35
|
+
*/
|
|
36
|
+
export type TimelineHooks = Hooks<"timeline", Events<RecordData>>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The id-scoped composable `createTimeline` returns. Call it in setup;
|
|
40
|
+
* every call yields a service over the same shared container.
|
|
41
|
+
*/
|
|
42
|
+
export type UseTimeline<T extends RecordData> = () => Service<T>;
|
package/app/types/views.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
BROWSER_VIEW_SCHEMA,
|
|
4
4
|
CALENDAR_VIEW_SCHEMA,
|
|
5
5
|
TABLE_VIEW_SCHEMA,
|
|
6
|
+
TIMELINE_VIEW_SCHEMA,
|
|
6
7
|
} from "../constants/views";
|
|
7
8
|
import type { Actions, Config, Events, Service } from "@zoobzio/views";
|
|
8
9
|
import type { z } from "zod";
|
|
@@ -25,6 +26,12 @@ export type BrowserView = z.output<typeof BROWSER_VIEW_SCHEMA>;
|
|
|
25
26
|
*/
|
|
26
27
|
export type CalendarView = z.output<typeof CALENDAR_VIEW_SCHEMA>;
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The payload of a timeline's saved view, as `TIMELINE_VIEW_SCHEMA` yields
|
|
31
|
+
* it: the timeline's `Snapshot`.
|
|
32
|
+
*/
|
|
33
|
+
export type TimelineView = z.output<typeof TIMELINE_VIEW_SCHEMA>;
|
|
34
|
+
|
|
28
35
|
/**
|
|
29
36
|
* What views are over: anything that yields its arrangement and takes one
|
|
30
37
|
* back. A table service, a browser service, and a calendar service are
|
package/app/utils/editor.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { IconAlias } from "../types/icon";
|
|
2
2
|
import type { AppMessage } from "../types/text";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
EDITOR_FIELD_TEXT,
|
|
6
|
+
EDITOR_TOOL_ICONS,
|
|
7
|
+
EDITOR_TOOL_TEXT,
|
|
8
|
+
} from "../constants/editor";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* The icon of an editor tool, by its key. A heading has none: it is an
|
|
@@ -22,3 +26,11 @@ export const toolText = (key: string): AppMessage | undefined => {
|
|
|
22
26
|
if (heading) return ["editor.heading", { level: Number(heading[1]) }];
|
|
23
27
|
return EDITOR_TOOL_TEXT[key];
|
|
24
28
|
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The text of a prompt's field, by its key, as a message of the contract.
|
|
32
|
+
* A field the layer does not name — one of a tool an app adds — has none,
|
|
33
|
+
* and its own label stands.
|
|
34
|
+
*/
|
|
35
|
+
export const fieldText = (key: string): AppMessage | undefined =>
|
|
36
|
+
EDITOR_FIELD_TEXT[key];
|
|
@@ -46,6 +46,7 @@ export const COMPONENTS = [
|
|
|
46
46
|
"table-head",
|
|
47
47
|
"tabs",
|
|
48
48
|
"tags-input",
|
|
49
|
+
"timeline",
|
|
49
50
|
"toast",
|
|
50
51
|
"toaster",
|
|
51
52
|
"tooltip",
|
|
@@ -96,6 +97,7 @@ export const WRAPPED = [
|
|
|
96
97
|
"table",
|
|
97
98
|
"tabs",
|
|
98
99
|
"tags-input",
|
|
100
|
+
"timeline",
|
|
99
101
|
"toast",
|
|
100
102
|
"tree",
|
|
101
103
|
"views",
|
|
@@ -139,6 +141,7 @@ export const DEFINITIONS = [
|
|
|
139
141
|
"table",
|
|
140
142
|
"tabs",
|
|
141
143
|
"tags-input",
|
|
144
|
+
"timeline",
|
|
142
145
|
"toast",
|
|
143
146
|
"toaster",
|
|
144
147
|
"tooltip",
|
|
@@ -158,7 +161,11 @@ export const LAYER = {
|
|
|
158
161
|
"composables/notification": ["useNotifications"],
|
|
159
162
|
"composables/request": ["useRequest", "useLazyRequest"],
|
|
160
163
|
"constants/calendar": ["CALENDAR_TOOL_ICONS", "CALENDAR_TOOL_TEXT"],
|
|
161
|
-
"constants/editor": [
|
|
164
|
+
"constants/editor": [
|
|
165
|
+
"EDITOR_TOOL_ICONS",
|
|
166
|
+
"EDITOR_TOOL_TEXT",
|
|
167
|
+
"EDITOR_FIELD_TEXT",
|
|
168
|
+
],
|
|
162
169
|
"constants/error": [
|
|
163
170
|
"ERROR_DEFAULT_STATUS_CODE",
|
|
164
171
|
"ERROR_NOT_FOUND_STATUS_CODE",
|
|
@@ -169,6 +176,7 @@ export const LAYER = {
|
|
|
169
176
|
"TABLE_VIEW_SCHEMA",
|
|
170
177
|
"BROWSER_VIEW_SCHEMA",
|
|
171
178
|
"CALENDAR_VIEW_SCHEMA",
|
|
179
|
+
"TIMELINE_VIEW_SCHEMA",
|
|
172
180
|
],
|
|
173
181
|
"factories/browser": ["createBrowser"],
|
|
174
182
|
"factories/calendar": ["createCalendar"],
|
|
@@ -176,6 +184,7 @@ export const LAYER = {
|
|
|
176
184
|
"factories/editor": ["createEditor"],
|
|
177
185
|
"factories/form": ["createForm"],
|
|
178
186
|
"factories/table": ["createTable"],
|
|
187
|
+
"factories/timeline": ["createTimeline"],
|
|
179
188
|
"factories/views": ["createViews"],
|
|
180
189
|
"stores/browser": ["accessBrowser"],
|
|
181
190
|
"stores/calendar": ["accessCalendar"],
|
|
@@ -185,6 +194,7 @@ export const LAYER = {
|
|
|
185
194
|
"stores/log": ["accessLogs"],
|
|
186
195
|
"stores/notification": ["accessNotifications"],
|
|
187
196
|
"stores/table": ["accessTable"],
|
|
197
|
+
"stores/timeline": ["accessTimeline"],
|
|
188
198
|
"stores/views": ["accessViews"],
|
|
189
199
|
"utils/text": ["resolveText", "resolveTexts"],
|
|
190
200
|
} as const satisfies Record<string, readonly string[]>;
|
|
@@ -236,10 +246,17 @@ export const LAYER_TYPES = {
|
|
|
236
246
|
"TableHooks",
|
|
237
247
|
"UseTable",
|
|
238
248
|
],
|
|
249
|
+
"types/timeline": [
|
|
250
|
+
"TimelineInitial",
|
|
251
|
+
"TimelineOptions",
|
|
252
|
+
"TimelineHooks",
|
|
253
|
+
"UseTimeline",
|
|
254
|
+
],
|
|
239
255
|
"types/views": [
|
|
240
256
|
"TableView",
|
|
241
257
|
"BrowserView",
|
|
242
258
|
"CalendarView",
|
|
259
|
+
"TimelineView",
|
|
243
260
|
"ViewsTarget",
|
|
244
261
|
"ViewsOptions",
|
|
245
262
|
"ViewsHooks",
|
|
@@ -688,6 +705,16 @@ export const VUE_TYPES = {
|
|
|
688
705
|
"TagsInputSlots",
|
|
689
706
|
"TagsInputDefinition",
|
|
690
707
|
],
|
|
708
|
+
"components/timeline": [
|
|
709
|
+
"TimelineItem",
|
|
710
|
+
"TimelineGroup",
|
|
711
|
+
"TimelinePassthrough",
|
|
712
|
+
"TimelineProps",
|
|
713
|
+
"TimelineEmits",
|
|
714
|
+
"TimelineContext",
|
|
715
|
+
"TimelineSlots",
|
|
716
|
+
"TimelineDefinition",
|
|
717
|
+
],
|
|
691
718
|
"components/toast": [
|
|
692
719
|
"ToastVariant",
|
|
693
720
|
"ToastPassthrough",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoobzio/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Nuxt layer for the foundation design system: the Nuxt wiring over @zoobzio/vue and the headless services (useState stores, hook-bus factories, app shell).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -47,19 +47,21 @@
|
|
|
47
47
|
"prosary": "0.0.11",
|
|
48
48
|
"reka-ui": "^2.6.0",
|
|
49
49
|
"untheme": "^0.6.1",
|
|
50
|
-
"@zoobzio/
|
|
51
|
-
"@zoobzio/
|
|
52
|
-
"@zoobzio/
|
|
53
|
-
"@zoobzio/
|
|
54
|
-
"@zoobzio/
|
|
55
|
-
"@zoobzio/icons": "0.1.
|
|
56
|
-
"@zoobzio/kit": "0.1.
|
|
57
|
-
"@zoobzio/prose": "0.1.
|
|
58
|
-
"@zoobzio/query": "0.1.
|
|
59
|
-
"@zoobzio/
|
|
60
|
-
"@zoobzio/
|
|
61
|
-
"@zoobzio/
|
|
62
|
-
"@zoobzio/
|
|
50
|
+
"@zoobzio/browser": "0.1.13",
|
|
51
|
+
"@zoobzio/calendar": "0.1.13",
|
|
52
|
+
"@zoobzio/code": "0.1.13",
|
|
53
|
+
"@zoobzio/editor": "0.1.13",
|
|
54
|
+
"@zoobzio/form": "0.1.13",
|
|
55
|
+
"@zoobzio/icons": "0.1.13",
|
|
56
|
+
"@zoobzio/kit": "0.1.13",
|
|
57
|
+
"@zoobzio/prose": "0.1.13",
|
|
58
|
+
"@zoobzio/query": "0.1.13",
|
|
59
|
+
"@zoobzio/sync": "0.1.13",
|
|
60
|
+
"@zoobzio/table": "0.1.13",
|
|
61
|
+
"@zoobzio/timeline": "0.1.13",
|
|
62
|
+
"@zoobzio/theme": "0.1.13",
|
|
63
|
+
"@zoobzio/views": "0.1.13",
|
|
64
|
+
"@zoobzio/vue": "0.1.13"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
67
|
"@codemirror/state": "^6.7.6",
|