@zoobzio/nuxt 0.1.11 → 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 CHANGED
@@ -147,16 +147,18 @@ names no icon of its own (the text literal, the one that opens the quote
147
147
  free text is typed in); `remove` on a tag's, a file's, and an image
148
148
  input's remove button, `image` in an image input's placeholder and
149
149
  `camera` before its pick label; `remove` also after an autocomplete chip's label; `close` on a toast's; `top` on a scroller's back-to-top; `check`
150
- in a checkbox; the editor's and rich text's tools by key (`bold`,
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
157
157
  the views keep their names as text; and on
158
158
  the table and browser, `refresh`, `columns`, `actions`, `drag`,
159
- `sort-asc` or `sort-desc` after a sorted header, `folder` before a
159
+ `sort-asc` or `sort-desc` after a sorted header, `pin` as the button of a
160
+ column's pin menu (`unpin` once the column is pinned) with `pin-start`,
161
+ `pin-end`, and `unpin` before its items, `folder` before a
160
162
  folder, `folder-open` before the root crumb of the browser's trail, `sort`
161
163
  as the browser's sort trigger until its files sort by a column and
162
164
  `sort-asc` or `sort-desc` from then on, as after that column's item in the
@@ -414,15 +416,23 @@ const users = useUsers(() => ({
414
416
  }));
415
417
  ```
416
418
 
417
- | Factory | Store | Hooks relayed |
418
- | ---------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
419
- | `createTable` | `accessTable` | `table:updated`, `table:filtered`, `table:restored` |
420
- | `createForm` | `accessForm` | `form:initialized`, `form:submitted`, `form:rejected`, `form:restored`, `form:reset`, `form:failed` |
421
- | `createBrowser` | `accessBrowser` | `browser:updated`, `browser:navigated`, `browser:filtered`, `browser:restored` |
422
- | `createEditor` | `accessEditor` | `editor:loaded`, `editor:updated`, `editor:mounted`, `editor:unmounted` |
423
- | `createCode` | `accessCode` | `code:loaded`, `code:updated`, `code:mounted`, `code:unmounted` |
424
- | `createCalendar` | `accessCalendar` | `calendar:navigated`, `calendar:loaded`, `calendar:changed`, `calendar:selected` |
425
- | `createViews` | `accessViews` | `views:initialized`, `views:selected`, `views:saved`, `views:renamed`, `views:removed`, `views:reverted`, `views:failed` |
419
+ | Factory | Store | Hooks relayed |
420
+ | ---------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------- |
421
+ | `createTable` | `accessTable` | `table:updated`, `table:filtered`, `table:restored` |
422
+ | `createForm` | `accessForm` | `form:initialized`, `form:submitted`, `form:rejected`, `form:restored`, `form:reset`, `form:failed` |
423
+ | `createBrowser` | `accessBrowser` | `browser:updated`, `browser:navigated`, `browser:filtered`, `browser:restored` |
424
+ | `createEditor` | `accessEditor` | `editor:loaded`, `editor:updated`, `editor:mounted`, `editor:unmounted` |
425
+ | `createCode` | `accessCode` | `code:loaded`, `code:updated`, `code:mounted`, `code:unmounted` |
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` |
428
+ | `createViews` | `accessViews` | `views:initialized`, `views:selected`, `views:saved`, `views:renamed`, `views:removed`, `views:reverted`, `views:failed` |
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.
426
436
 
427
437
  Every relayed payload carries the service's `id`. `useHooks` subscribes
428
438
  for one instance: each listener fires for events with that id only, and
@@ -442,9 +452,12 @@ Each relay is also logged at `debug` under the service's id (see
442
452
 
443
453
  `createViews` builds saved views over another service. Its composable
444
454
  takes what the views are over, anything with a `snapshot` and a `restore`,
445
- which a table and a browser service each have; `TABLE_VIEW_SCHEMA` and
446
- `BROWSER_VIEW_SCHEMA` are the Zod schemas of what each yields, and
447
- `TableView` and `BrowserView` their types. Without a `load`, a `save`, and
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
448
461
  a `remove` the views live in the store alone.
449
462
 
450
463
  ```ts
@@ -592,7 +605,7 @@ app/
592
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
593
606
  error.vue — the error page
594
607
  app.d.ts — RuntimeNuxtHooks augmentation for the relayed events; the vue item types and the headless action descriptors widened with `icon`
595
- 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 and a browser's saved view
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
596
609
  assets/css/ — reset.css, loaded by the layer config
597
610
  composables/ — useAppError, useFocusKey, useHooks, useLogger, useNotifications, useRequest, useLazyRequest
598
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. The root crumb draws `folder-open`, a crumb below it its own `icon`,
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"),
@@ -1,8 +1,15 @@
1
1
  // The vue calendar with its toolbar dressed: each tool is named in the
2
2
  // visitor's locale, the name its accessible name and its tooltip, and the
3
3
  // two steps draw their icons in place of their labels; today and the views
4
- // keep their names as text. An untitled occurrence and the empty agenda
5
- // read in the visitor's locale too.
4
+ // keep their names as text. Its search, where the service is searchable,
5
+ // is the layer's TableSearch (the Autocomplete with the `magic` icon, the
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;
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
11
+ // untitled occurrence and the empty agenda read in the visitor's locale
12
+ // too.
6
13
  import type {
7
14
  CalendarPassthrough,
8
15
  CalendarTool,
@@ -14,7 +21,10 @@ import Core from "@zoobzio/vue/components/calendar.vue";
14
21
  import { h } from "vue";
15
22
  import { layer } from "@zoobzio/vue/utils/passthrough";
16
23
  import { wrap } from "@zoobzio/vue/utils/wrap";
17
- import { iconOf } from "./icon";
24
+ import Menu from "./menu";
25
+ import TableSearch from "./table-search";
26
+ import { syncLabel, syncMark } from "./sync";
27
+ import { iconOf, iconPart } from "./icon";
18
28
  import { text, textIn, textSlot } from "./text";
19
29
  import { toolIcon, toolText } from "../utils/calendar";
20
30
 
@@ -40,8 +50,17 @@ const toolLabel = (tool: CalendarTool): VNode[] => {
40
50
  };
41
51
 
42
52
  export default wrap(Core, {
43
- pt: (pt) => layer<CalendarPassthrough>(pt, { tool: toolLayer }),
53
+ pt: (pt) =>
54
+ layer<CalendarPassthrough>(pt, {
55
+ search: { as: TableSearch, placeholder: text("calendar.search") },
56
+ refresh: { label: text("calendar.refresh") },
57
+ syncMenu: { as: Menu },
58
+ tool: toolLayer,
59
+ }),
44
60
  slots: {
61
+ refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
62
+ syncLabel: ({ item }) => syncLabel(item),
63
+ syncAppend: ({ calendar, item }) => syncMark(calendar.sync, item),
45
64
  toolLabel: ({ tool }) => toolLabel(tool),
46
65
  // A title is the entry's own text, never a message; only the name of
47
66
  // an entry without one is the layer's.
@@ -1,9 +1,15 @@
1
- // The vue checkbox with the `check` icon as its indicator.
1
+ // The vue checkbox with the `check` icon as its indicator, and
2
+ // `indeterminate` in its place while the checkbox is neither on nor off: a
3
+ // select-all over some of the rows.
2
4
  import Core from "@zoobzio/vue/components/checkbox.vue";
3
5
 
4
6
  import { icon } from "./icon";
5
7
  import { wrap } from "@zoobzio/vue/utils/wrap";
6
8
 
7
9
  export default wrap(Core, {
8
- slots: { icon: () => [icon("check")] },
10
+ slots: {
11
+ icon: ({ modelValue }) => [
12
+ icon(modelValue.value === "indeterminate" ? "indeterminate" : "check"),
13
+ ],
14
+ },
9
15
  });
@@ -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, and the block type dropdown's trigger and items in
4
- // the visitor's locale. It sits with the wrappers, as `icon.ts` and
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");
@@ -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 reads in the visitor's locale.
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")] : [];
@@ -5,10 +5,15 @@
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; the
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
- // header, and `sort-asc` or `sort-desc` after a sorted header; a bulk action
11
- // draws its own `icon`. Its own text — the toolbar's labels and
13
+ // header, and `sort-asc` or `sort-desc` after a sorted header; a column's
14
+ // pin menu is the layer's Menu, opened by `pin` (`unpin` on a pinned
15
+ // column), its items drawn with `pin-start`, `pin-end`, and `unpin`; a bulk
16
+ // action draws its own `icon`. Its own text — the toolbar's labels and
12
17
  // placeholders, the empty state, the clear button, the name of a column's
13
18
  // resizer — reads in the
14
19
  // visitor's locale, and a date, number, currency, file size or boolean
@@ -23,7 +28,7 @@ import type { TableColumnsPassthrough } from "@zoobzio/vue/types/components/tabl
23
28
  import type { TableHeadPassthrough } from "@zoobzio/vue/types/components/table-head";
24
29
 
25
30
  import Core from "@zoobzio/vue/components/table.vue";
26
- import { columnLabel } from "@zoobzio/vue/utils/table";
31
+ import { columnLabel, pinItems } from "@zoobzio/vue/utils/table";
27
32
 
28
33
  import NuxtLink from "#app/components/nuxt-link";
29
34
  import { layer } from "@zoobzio/vue/utils/passthrough";
@@ -36,8 +41,16 @@ import Scroller from "./scroller";
36
41
  import TableSearch from "./table-search";
37
42
  import { icon, iconOf, iconPart } from "./icon";
38
43
  import { cellSlots } from "./cell";
44
+ import { syncLabel, syncMark } from "./sync";
39
45
  import { text, textSlot } from "./text";
40
46
 
47
+ /** The icon of each item of a column's pin menu. */
48
+ const PIN_ICONS = {
49
+ start: "pin-start",
50
+ end: "pin-end",
51
+ none: "unpin",
52
+ } as const;
53
+
41
54
  export default wrap(Core, {
42
55
  pt: (pt) => ({
43
56
  ...pt,
@@ -47,6 +60,7 @@ export default wrap(Core, {
47
60
  ...pt?.search,
48
61
  },
49
62
  refresh: { label: text("table.refresh"), ...pt?.refresh },
63
+ syncMenu: { as: Menu, ...pt?.syncMenu },
50
64
  pagination: { as: Pagination, ...pt?.pagination },
51
65
  scroller: { as: Scroller, ...pt?.scroller },
52
66
  head: layer<TableHeadPassthrough<RowData>>(pt?.head, {
@@ -56,6 +70,22 @@ export default wrap(Core, {
56
70
  column: text(columnLabel(column)),
57
71
  }),
58
72
  }),
73
+ pinMenu: (column) => ({
74
+ as: Menu,
75
+ groups: [
76
+ {
77
+ key: "pin",
78
+ items: pinItems(column, {
79
+ start: text("table.pinStart"),
80
+ end: text("table.pinEnd"),
81
+ none: text("table.unpin"),
82
+ }).map((item) => ({ ...item, icon: PIN_ICONS[item.key] })),
83
+ },
84
+ ],
85
+ }),
86
+ pinTrigger: (column) => ({
87
+ label: text("table.pin", { column: text(columnLabel(column)) }),
88
+ }),
59
89
  }),
60
90
  body: layer<TableBodyPassthrough<RowData>>(pt?.body, {
61
91
  link: () => ({ as: NuxtLink }),
@@ -71,9 +101,16 @@ export default wrap(Core, {
71
101
  slots: {
72
102
  ...cellSlots<TableCellContext<RowData>>(({ table }) => table),
73
103
  refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
104
+ syncLabel: ({ item }) => syncLabel(item),
105
+ syncAppend: ({ table, item }) => syncMark(table.sync, item),
74
106
  columns: ({ settings }) => iconPart(settings.trigger, "columns"),
75
107
  actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
76
108
  dragPrepend: () => [icon("drag")],
109
+ pin: ({ settings, column }) =>
110
+ iconPart(
111
+ { ...settings.pinTrigger(column), class: "f-data-table-pin" },
112
+ column.getIsPinned() ? "unpin" : "pin",
113
+ ),
77
114
  headerPrepend: ({ column }) => iconOf(column.columnDef.meta?.icon),
78
115
  headerAppend: ({ column }) => {
79
116
  const sorted = column.getIsSorted();
@@ -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
+ });
@@ -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 blocks,
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
+ };
@@ -1,6 +1,12 @@
1
1
  import { z } from "zod";
2
2
 
3
- const entry = z.discriminatedUnion("kind", [
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
+
9
+ const clause = z.discriminatedUnion("kind", [
4
10
  z.object({
5
11
  kind: z.literal("literal"),
6
12
  key: z.string(),
@@ -14,27 +20,78 @@ const entry = z.discriminatedUnion("kind", [
14
20
  }),
15
21
  ]);
16
22
 
23
+ /**
24
+ * A stored payload as the schemas read it: one saved while the query's
25
+ * clauses were its `entries` carries them under `clauses`, so a view
26
+ * stored before the rename keeps its search rather than reading as none.
27
+ */
28
+ const renamed = (payload: unknown): unknown => {
29
+ if (typeof payload !== "object" || payload === null) return payload;
30
+ if (!("entries" in payload) || "clauses" in payload) return payload;
31
+ const { entries, ...rest } = payload;
32
+ return { ...rest, clauses: entries };
33
+ };
34
+
17
35
  /**
18
36
  * The schema of a table's saved view: what the table's `snapshot` yields
19
37
  * and its `restore` takes. Hand it to `createViews` for views over a
20
38
  * table. Every member has a default, so a view stored before a member
21
- * existed still reads; an app with more to save in a view extends it.
39
+ * existed still reads; an app with more to save in a view extends the
40
+ * object the schema reads into, its `out`.
41
+ */
42
+ export const TABLE_VIEW_SCHEMA = z.preprocess(
43
+ renamed,
44
+ z.object({
45
+ sorting: z
46
+ .array(z.object({ id: z.string(), desc: z.boolean() }))
47
+ .default([]),
48
+ columnOrder: z.array(z.string()).default([]),
49
+ columnPinning: z
50
+ .object({
51
+ start: z.array(z.string()).default([]),
52
+ end: z.array(z.string()).default([]),
53
+ })
54
+ .default({ start: [], end: [] }),
55
+ columnVisibility: z.record(z.string(), z.boolean()).default({}),
56
+ columnSizing: z.record(z.string(), z.number()).default({}),
57
+ pageSize: z.number().int().positive().default(10),
58
+ clauses: z.array(clause).default([]),
59
+ interval,
60
+ }),
61
+ );
62
+
63
+ /**
64
+ * The schema of a calendar's saved view: what the calendar's `snapshot`
65
+ * yields and its `restore` takes. The view alone, the search, and the
66
+ * sync's interval: a saved
67
+ * view opens on the day the calendar stands on.
22
68
  */
23
- export const TABLE_VIEW_SCHEMA = z.object({
24
- sorting: z.array(z.object({ id: z.string(), desc: z.boolean() })).default([]),
25
- columnOrder: z.array(z.string()).default([]),
26
- columnVisibility: z.record(z.string(), z.boolean()).default({}),
27
- columnSizing: z.record(z.string(), z.number()).default({}),
28
- pageSize: z.number().int().positive().default(10),
29
- entries: z.array(entry).default([]),
69
+ export const CALENDAR_VIEW_SCHEMA = z.object({
70
+ view: z.enum(["month", "week", "day", "agenda"]).default("month"),
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,
30
83
  });
31
84
 
32
85
  /**
33
86
  * The schema of a browser's saved view: what the browser's `snapshot`
34
87
  * yields and its `restore` takes.
35
88
  */
36
- export const BROWSER_VIEW_SCHEMA = z.object({
37
- sortField: z.string().nullable().default(null),
38
- sortDirection: z.enum(["asc", "desc"]).default("asc"),
39
- entries: z.array(entry).default([]),
40
- });
89
+ export const BROWSER_VIEW_SCHEMA = z.preprocess(
90
+ renamed,
91
+ z.object({
92
+ sortField: z.string().nullable().default(null),
93
+ sortDirection: z.enum(["asc", "desc"]).default("asc"),
94
+ clauses: z.array(clause).default([]),
95
+ interval,
96
+ }),
97
+ );
@@ -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. The machine itself is
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 { fetch, actions, folderActions, bulkActions, initial, ...rest } =
33
- options;
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
  };
@@ -3,7 +3,9 @@ import type { Actions, Config, Service } from "@zoobzio/calendar";
3
3
 
4
4
  import { useNuxtApp } from "#app";
5
5
  import { CalendarService } from "@zoobzio/calendar";
6
+ import { QUERY_TEXT_KEY, QUERY_TEXT_LITERAL } from "@zoobzio/query";
6
7
  import { accessCalendar } from "../stores/calendar";
8
+ import { resolveTexts } from "../utils/text";
7
9
 
8
10
  /**
9
11
  * Builds the id-scoped composable of a calendar. Call it at module scope:
@@ -11,22 +13,51 @@ import { accessCalendar } from "../stores/calendar";
11
13
  * reader, the writer, the fetch, the save), and `id` keys everything that
12
14
  * follows. Each call of the composable, in setup, builds a service over
13
15
  * the id's shared store and relays its domain events onto the app logger
14
- * and the Nuxt hook bus under the `calendar:` prefix. The machine itself
15
- * is `@zoobzio/calendar`; the Vue calendar renders it through its
16
- * `service` prop.
16
+ * and the Nuxt hook bus under the `calendar:` prefix. Every text of the
17
+ * config, the labels of the query's fields and literals, resolves through
18
+ * the app's prosary service as the service is built, so a label that is a
19
+ * key of the app's contract reaches the machine, and the search that
20
+ * matches a typed prefix against it, as the visitor reads it. A config
21
+ * that searches and names no literals takes the query's text literal
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
25
+ * `@zoobzio/calendar`; the Vue calendar renders it through its `service`
26
+ * prop.
17
27
  */
18
28
  export const createCalendar = <I, O>(
19
29
  id: string,
20
30
  options: CalendarOptions<I, O>,
21
31
  ): UseCalendar<I, O> => {
22
- const { read, write, fetch, save, now, uid, initial, ...config } = options;
23
- const wiring: Actions<I, O> = { read, write, fetch, save, now, uid };
24
- const settings: Config = config;
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
+ };
43
+ // A calendar that names neither fields nor literals renders no search,
44
+ // and naming the literal here would say it does.
45
+ const searches = config.searchable ?? config.fields !== undefined;
46
+ const settings: Config = {
47
+ ...config,
48
+ ...(searches &&
49
+ config.literals === undefined && {
50
+ literals: {
51
+ [QUERY_TEXT_KEY]: { ...QUERY_TEXT_LITERAL, label: "calendar.text" },
52
+ },
53
+ }),
54
+ };
25
55
  return (): Service<I, O> => {
26
56
  const nuxt = useNuxtApp();
27
57
  const log = nuxt.$logger(id);
28
- const state = accessCalendar(id, settings, initial);
29
- const service = new CalendarService<I, O>(id, settings, state, wiring);
58
+ const resolved = resolveTexts(nuxt.$prosary, settings);
59
+ const state = accessCalendar(id, resolved, initial);
60
+ const service = new CalendarService<I, O>(id, resolved, state, wiring);
30
61
  service.on("navigated", (event) => {
31
62
  log.debug("Calendar navigated", event);
32
63
  nuxt.callHook("calendar:navigated", event);
@@ -43,6 +74,19 @@ export const createCalendar = <I, O>(
43
74
  log.debug("Calendar selected", event);
44
75
  nuxt.callHook("calendar:selected", event);
45
76
  });
77
+ service.on("filtered", (event) => {
78
+ log.debug("Calendar filtered", event);
79
+ nuxt.callHook("calendar:filtered", event);
80
+ });
81
+ service.on("restored", (event) => {
82
+ log.debug("Calendar restored", event);
83
+ nuxt.callHook("calendar:restored", event);
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
+ });
46
90
  return service;
47
91
  };
48
92
  };
@@ -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. The machine itself is `@zoobzio/table`;
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
+ };
@@ -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. It shapes the record once, when it is first created; later
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;
@@ -8,7 +8,7 @@ import { createTableState } from "@zoobzio/table";
8
8
  * keyed `table-<id>`. Its value is a reactive proxy, so the service's field
9
9
  * writes are tracked; instances sharing an id share the container across
10
10
  * the app, and it survives SSR hydration. `config` shapes the record once,
11
- * when it is first created, its `initialState` and `initialEntries`
11
+ * when it is first created, its `initialState` and `initialClauses`
12
12
  * included; later calls under the same id get the record as it stands.
13
13
  */
14
14
  export const accessTable = <T extends RowData>(
@@ -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;
@@ -33,7 +33,7 @@ export type BrowserBulkAction = Bound<ActionDescriptor, BulkAction["action"]>;
33
33
 
34
34
  /**
35
35
  * The slice of the state container a browser may start from: the trail,
36
- * the file sort, the selection, and the search's entries the consumer
36
+ * the file sort, the selection, and the search's clauses the consumer
37
37
  * chooses, never what a fetch fills in. It seeds the `useState` record, so it must survive Nuxt's
38
38
  * payload (devalue carries the `Set`).
39
39
  */
@@ -45,13 +45,14 @@ export type BrowserInitial<T> = Partial<
45
45
  | "sortDirection"
46
46
  | "selected"
47
47
  | "selectedFolders"
48
- | "entries"
48
+ | "clauses"
49
49
  >
50
50
  >;
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, and the initial
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>;
@@ -28,8 +28,8 @@ export type CalendarOptions<I, O> = Config &
28
28
 
29
29
  /**
30
30
  * The Nuxt hooks a calendar relays: `calendar:navigated`,
31
- * `calendar:loaded`, `calendar:changed`, and `calendar:selected`, each
32
- * carrying the service's payload with its scoping `id`.
31
+ * `calendar:loaded`, `calendar:changed`, `calendar:selected`,
32
+ * `calendar:filtered`, and `calendar:restored`, each carrying the service's payload with its scoping `id`.
33
33
  */
34
34
  export type CalendarHooks = Hooks<"calendar", Events<unknown>>;
35
35
 
@@ -29,8 +29,9 @@ 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, and the fetch mechanism. The config's
33
- * `initialState` and `initialEntries` are what the table starts from: they
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
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
  */
36
37
  export type TableOptions<T extends RowData> = Omit<
@@ -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>;
@@ -1,7 +1,9 @@
1
1
  import type { Hooks } from "./hooks";
2
2
  import type {
3
3
  BROWSER_VIEW_SCHEMA,
4
+ CALENDAR_VIEW_SCHEMA,
4
5
  TABLE_VIEW_SCHEMA,
6
+ TIMELINE_VIEW_SCHEMA,
5
7
  } from "../constants/views";
6
8
  import type { Actions, Config, Events, Service } from "@zoobzio/views";
7
9
  import type { z } from "zod";
@@ -18,9 +20,22 @@ export type TableView = z.output<typeof TABLE_VIEW_SCHEMA>;
18
20
  */
19
21
  export type BrowserView = z.output<typeof BROWSER_VIEW_SCHEMA>;
20
22
 
23
+ /**
24
+ * The payload of a calendar's saved view, as `CALENDAR_VIEW_SCHEMA` yields
25
+ * it: the calendar's `Snapshot`.
26
+ */
27
+ export type CalendarView = z.output<typeof CALENDAR_VIEW_SCHEMA>;
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
+
21
35
  /**
22
36
  * What views are over: anything that yields its arrangement and takes one
23
- * back. A table service and a browser service are each one. `snapshot`
37
+ * back. A table service, a browser service, and a calendar service are
38
+ * each one. `snapshot`
24
39
  * must read reactive state for the drift to show.
25
40
  */
26
41
  export type ViewsTarget<P> = {
@@ -1,7 +1,11 @@
1
1
  import type { IconAlias } from "../types/icon";
2
2
  import type { AppMessage } from "../types/text";
3
3
 
4
- import { EDITOR_TOOL_ICONS, EDITOR_TOOL_TEXT } from "../constants/editor";
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,20 +161,30 @@ 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": ["EDITOR_TOOL_ICONS", "EDITOR_TOOL_TEXT"],
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",
165
172
  ],
166
173
  "constants/log": ["LOG_ROOT_NAME", "LOG_LEVELS"],
167
174
  "constants/table": ["TABLE_SEARCH_KEY"],
168
- "constants/views": ["TABLE_VIEW_SCHEMA", "BROWSER_VIEW_SCHEMA"],
175
+ "constants/views": [
176
+ "TABLE_VIEW_SCHEMA",
177
+ "BROWSER_VIEW_SCHEMA",
178
+ "CALENDAR_VIEW_SCHEMA",
179
+ "TIMELINE_VIEW_SCHEMA",
180
+ ],
169
181
  "factories/browser": ["createBrowser"],
170
182
  "factories/calendar": ["createCalendar"],
171
183
  "factories/code": ["createCode"],
172
184
  "factories/editor": ["createEditor"],
173
185
  "factories/form": ["createForm"],
174
186
  "factories/table": ["createTable"],
187
+ "factories/timeline": ["createTimeline"],
175
188
  "factories/views": ["createViews"],
176
189
  "stores/browser": ["accessBrowser"],
177
190
  "stores/calendar": ["accessCalendar"],
@@ -181,6 +194,7 @@ export const LAYER = {
181
194
  "stores/log": ["accessLogs"],
182
195
  "stores/notification": ["accessNotifications"],
183
196
  "stores/table": ["accessTable"],
197
+ "stores/timeline": ["accessTimeline"],
184
198
  "stores/views": ["accessViews"],
185
199
  "utils/text": ["resolveText", "resolveTexts"],
186
200
  } as const satisfies Record<string, readonly string[]>;
@@ -232,9 +246,17 @@ export const LAYER_TYPES = {
232
246
  "TableHooks",
233
247
  "UseTable",
234
248
  ],
249
+ "types/timeline": [
250
+ "TimelineInitial",
251
+ "TimelineOptions",
252
+ "TimelineHooks",
253
+ "UseTimeline",
254
+ ],
235
255
  "types/views": [
236
256
  "TableView",
237
257
  "BrowserView",
258
+ "CalendarView",
259
+ "TimelineView",
238
260
  "ViewsTarget",
239
261
  "ViewsOptions",
240
262
  "ViewsHooks",
@@ -683,6 +705,16 @@ export const VUE_TYPES = {
683
705
  "TagsInputSlots",
684
706
  "TagsInputDefinition",
685
707
  ],
708
+ "components/timeline": [
709
+ "TimelineItem",
710
+ "TimelineGroup",
711
+ "TimelinePassthrough",
712
+ "TimelineProps",
713
+ "TimelineEmits",
714
+ "TimelineContext",
715
+ "TimelineSlots",
716
+ "TimelineDefinition",
717
+ ],
686
718
  "components/toast": [
687
719
  "ToastVariant",
688
720
  "ToastPassthrough",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoobzio/nuxt",
3
- "version": "0.1.11",
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/browser": "0.1.11",
51
- "@zoobzio/calendar": "0.1.11",
52
- "@zoobzio/code": "0.1.11",
53
- "@zoobzio/form": "0.1.11",
54
- "@zoobzio/editor": "0.1.11",
55
- "@zoobzio/icons": "0.1.11",
56
- "@zoobzio/kit": "0.1.11",
57
- "@zoobzio/prose": "0.1.11",
58
- "@zoobzio/query": "0.1.11",
59
- "@zoobzio/table": "0.1.11",
60
- "@zoobzio/theme": "0.1.11",
61
- "@zoobzio/views": "0.1.11",
62
- "@zoobzio/vue": "0.1.11"
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",