@zoobzio/nuxt 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -1
- package/app/app.d.ts +14 -0
- package/app/app.vue +4 -8
- package/app/components/accordion.ts +4 -2
- package/app/components/autocomplete.ts +6 -10
- package/app/components/breadcrumb.ts +8 -2
- package/app/components/browser.ts +30 -6
- package/app/components/cell.ts +101 -0
- package/app/components/code.ts +28 -0
- package/app/components/command.ts +10 -1
- package/app/components/date-filters.ts +42 -9
- package/app/components/dialog.ts +13 -0
- package/app/components/directory.ts +4 -2
- package/app/components/editor.ts +8 -4
- package/app/components/fab.ts +9 -0
- package/app/components/facets.ts +14 -4
- package/app/components/form-field.ts +4 -3
- package/app/components/form.ts +20 -2
- package/app/components/hero.ts +8 -1
- package/app/components/keywords.ts +35 -8
- package/app/components/listbox.ts +9 -0
- package/app/components/menu.ts +9 -3
- package/app/components/multi-select.ts +10 -2
- package/app/components/pagination.ts +33 -3
- package/app/components/radio.ts +9 -0
- package/app/components/rich-text.ts +8 -4
- package/app/components/segmented-control.ts +4 -2
- package/app/components/select.ts +9 -1
- package/app/components/table.ts +22 -4
- package/app/components/tabs.ts +4 -2
- package/app/components/tags-input.ts +7 -1
- package/app/components/text.ts +71 -0
- package/app/components/toast.ts +8 -1
- package/app/components/tree.ts +4 -2
- package/app/composables/request.ts +6 -3
- package/app/constants/editor.ts +21 -0
- package/app/error.vue +8 -4
- package/app/factories/browser.ts +13 -4
- package/app/factories/form.ts +11 -4
- package/app/factories/table.ts +15 -4
- package/app/plugins/locale.ts +19 -0
- package/app/types/text.ts +12 -0
- package/app/utils/editor.ts +14 -1
- package/app/utils/text.ts +90 -0
- package/modules/imports/constant.ts +8 -1
- package/nuxt.config.ts +3 -1
- package/package.json +14 -10
package/app/components/hero.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
// The vue hero with NuxtLink under its `link` part
|
|
1
|
+
// The vue hero with NuxtLink under its `link` part, and its description and
|
|
2
|
+
// action resolved.
|
|
2
3
|
import Core from "@zoobzio/vue/components/hero.vue";
|
|
3
4
|
|
|
4
5
|
import NuxtLink from "#app/components/nuxt-link";
|
|
5
6
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
|
+
import { textIf, texts } from "./text";
|
|
6
8
|
|
|
7
9
|
export default wrap(Core, {
|
|
10
|
+
props: (props) => ({
|
|
11
|
+
...props,
|
|
12
|
+
description: textIf(props.description),
|
|
13
|
+
action: texts(props.action),
|
|
14
|
+
}),
|
|
8
15
|
pt: { link: { as: NuxtLink } },
|
|
9
16
|
});
|
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
// The vue keywords with the
|
|
2
|
-
// the
|
|
3
|
-
//
|
|
1
|
+
// The vue keywords with the layer's TagsInput and SegmentedControl behind
|
|
2
|
+
// its controls, the `keywords` icon as its trigger's content, and its text
|
|
3
|
+
// — the trigger, the section headings, the placeholders, the match modes —
|
|
4
|
+
// in the visitor's locale.
|
|
4
5
|
import Core from "@zoobzio/vue/components/keywords.vue";
|
|
5
6
|
|
|
7
|
+
import { h } from "vue";
|
|
6
8
|
import { iconPart } from "./icon";
|
|
9
|
+
import { text } from "./text";
|
|
7
10
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
8
11
|
import SegmentedControl from "./segmented-control";
|
|
9
12
|
import TagsInput from "./tags-input";
|
|
10
13
|
|
|
14
|
+
const caption = (label: string) => [
|
|
15
|
+
h("div", { class: "f-caption f-keywords-label" }, label),
|
|
16
|
+
];
|
|
17
|
+
|
|
11
18
|
export default wrap(Core, {
|
|
12
|
-
pt: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
pt: (pt) => ({
|
|
20
|
+
...pt,
|
|
21
|
+
trigger: { label: text("keywords.trigger"), ...pt?.trigger },
|
|
22
|
+
includeInput: {
|
|
23
|
+
as: TagsInput,
|
|
24
|
+
placeholder: text("keywords.include"),
|
|
25
|
+
...pt?.includeInput,
|
|
26
|
+
},
|
|
27
|
+
excludeInput: {
|
|
28
|
+
as: TagsInput,
|
|
29
|
+
placeholder: text("keywords.exclude"),
|
|
30
|
+
...pt?.excludeInput,
|
|
31
|
+
},
|
|
32
|
+
matchControl: {
|
|
33
|
+
as: SegmentedControl,
|
|
34
|
+
options: [
|
|
35
|
+
{ value: "and", label: text("keywords.and") },
|
|
36
|
+
{ value: "or", label: text("keywords.or") },
|
|
37
|
+
],
|
|
38
|
+
...pt?.matchControl,
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
17
41
|
slots: {
|
|
18
42
|
trigger: ({ settings }) => iconPart(settings.trigger, "keywords"),
|
|
43
|
+
includeLabel: () => caption(text("keywords.includeLabel")),
|
|
44
|
+
excludeLabel: () => caption(text("keywords.excludeLabel")),
|
|
45
|
+
matchLabel: () => caption(text("keywords.match")),
|
|
19
46
|
},
|
|
20
47
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The vue listbox with its items' text resolved.
|
|
2
|
+
import Core from "@zoobzio/vue/components/listbox.vue";
|
|
3
|
+
|
|
4
|
+
import { texts } from "./text";
|
|
5
|
+
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
|
+
|
|
7
|
+
export default wrap(Core, {
|
|
8
|
+
props: (props) => ({ ...props, items: texts(props.items) }),
|
|
9
|
+
});
|
package/app/components/menu.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
// The vue menu with NuxtLink under its `link` part,
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// The vue menu with NuxtLink under its `link` part, an item's `icon` before
|
|
2
|
+
// its label, and its text — the label, the groups and their items —
|
|
3
|
+
// resolved.
|
|
4
4
|
import Core from "@zoobzio/vue/components/menu.vue";
|
|
5
5
|
|
|
6
6
|
import NuxtLink from "#app/components/nuxt-link";
|
|
7
7
|
import { Icon } from "#components";
|
|
8
8
|
import { h } from "vue";
|
|
9
9
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
10
|
+
import { textIf, texts } from "./text";
|
|
10
11
|
|
|
11
12
|
export default wrap(Core, {
|
|
13
|
+
props: (props) => ({
|
|
14
|
+
...props,
|
|
15
|
+
label: textIf(props.label),
|
|
16
|
+
groups: texts(props.groups),
|
|
17
|
+
}),
|
|
12
18
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
13
19
|
slots: {
|
|
14
20
|
itemPrepend: ({ item }) =>
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
// The vue multi
|
|
2
|
-
//
|
|
1
|
+
// The vue multi-select with the layer's Checkbox rendering each item's
|
|
2
|
+
// checkbox, the `expand` icon after its trigger, and its text — the
|
|
3
|
+
// options, the selection, the placeholder — resolved.
|
|
3
4
|
import Core from "@zoobzio/vue/components/multi-select.vue";
|
|
4
5
|
|
|
5
6
|
import { icon } from "./icon";
|
|
7
|
+
import { textOr, texts } from "./text";
|
|
6
8
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
9
|
import Checkbox from "./checkbox";
|
|
8
10
|
|
|
9
11
|
export default wrap(Core, {
|
|
12
|
+
props: (props) => ({
|
|
13
|
+
...props,
|
|
14
|
+
items: texts(props.items),
|
|
15
|
+
modelValue: texts(props.modelValue),
|
|
16
|
+
placeholder: textOr(props.placeholder, "select.multiple"),
|
|
17
|
+
}),
|
|
10
18
|
pt: { itemCheckbox: () => ({ as: Checkbox }) },
|
|
11
19
|
slots: { triggerAppend: () => [icon("expand")] },
|
|
12
20
|
});
|
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
// The vue pagination with the `first`, `prev`, `next`, and `last` icons as
|
|
2
|
-
// the content of its page controls,
|
|
3
|
-
//
|
|
2
|
+
// the content of its page controls, the layer's Select as its size control,
|
|
3
|
+
// and its text — the controls' names, the summary, the sizes — in the
|
|
4
|
+
// visitor's locale.
|
|
4
5
|
import Core from "@zoobzio/vue/components/pagination.vue";
|
|
5
6
|
|
|
7
|
+
import { h } from "vue";
|
|
6
8
|
import { iconPart } from "./icon";
|
|
9
|
+
import { text, textPart } from "./text";
|
|
7
10
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
8
11
|
import Select from "./select";
|
|
9
12
|
|
|
10
13
|
export default wrap(Core, {
|
|
11
|
-
pt:
|
|
14
|
+
pt: (pt) => ({
|
|
15
|
+
...pt,
|
|
16
|
+
first: { label: text("pagination.first"), ...pt?.first },
|
|
17
|
+
prev: { label: text("pagination.previous"), ...pt?.prev },
|
|
18
|
+
next: { label: text("pagination.next"), ...pt?.next },
|
|
19
|
+
last: { label: text("pagination.last"), ...pt?.last },
|
|
20
|
+
size: { as: Select, ...pt?.size },
|
|
21
|
+
}),
|
|
12
22
|
slots: {
|
|
23
|
+
info: ({ page, count, total }) => [
|
|
24
|
+
h(
|
|
25
|
+
"span",
|
|
26
|
+
{ class: "f-span" },
|
|
27
|
+
text("pagination.info", { page: page.value, count, total }),
|
|
28
|
+
),
|
|
29
|
+
],
|
|
13
30
|
first: ({ settings }) => iconPart(settings.first, "first"),
|
|
14
31
|
prev: ({ settings }) => iconPart(settings.prev, "prev"),
|
|
15
32
|
next: ({ settings }) => iconPart(settings.next, "next"),
|
|
16
33
|
last: ({ settings }) => iconPart(settings.last, "last"),
|
|
34
|
+
// The size options read in the visitor's locale; the selected one is
|
|
35
|
+
// the option of the same value among them.
|
|
36
|
+
size: ({ settings }) => {
|
|
37
|
+
const options = settings.size.options.map((option) => ({
|
|
38
|
+
...option,
|
|
39
|
+
label: text("pagination.size", { size: Number(option.value) }),
|
|
40
|
+
}));
|
|
41
|
+
const current = settings.size.modelValue?.value;
|
|
42
|
+
return textPart(settings.size, {
|
|
43
|
+
options,
|
|
44
|
+
modelValue: options.find((option) => option.value === current),
|
|
45
|
+
});
|
|
46
|
+
},
|
|
17
47
|
},
|
|
18
48
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The vue radio with its options' text resolved.
|
|
2
|
+
import Core from "@zoobzio/vue/components/radio.vue";
|
|
3
|
+
|
|
4
|
+
import { texts } from "./text";
|
|
5
|
+
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
|
+
|
|
7
|
+
export default wrap(Core, {
|
|
8
|
+
props: (props) => ({ ...props, options: texts(props.options) }),
|
|
9
|
+
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
// The vue rich text with each tool's icon
|
|
2
|
-
//
|
|
1
|
+
// The vue rich text with each tool's icon before its label, and the label
|
|
2
|
+
// in the visitor's locale.
|
|
3
3
|
import Core from "@zoobzio/vue/components/rich-text.vue";
|
|
4
4
|
|
|
5
5
|
import { iconOf } from "./icon";
|
|
6
|
+
import { textSlot } from "./text";
|
|
6
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
|
-
import { toolIcon } from "../utils/editor";
|
|
8
|
+
import { toolIcon, toolText } from "../utils/editor";
|
|
8
9
|
|
|
9
10
|
export default wrap(Core, {
|
|
10
|
-
slots: {
|
|
11
|
+
slots: {
|
|
12
|
+
toolPrepend: ({ tool }) => iconOf(toolIcon(tool.key)),
|
|
13
|
+
toolLabel: ({ tool }) => textSlot(toolText(tool.key) ?? tool.label),
|
|
14
|
+
},
|
|
11
15
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// The vue segmented control with NuxtLink under its `link` part
|
|
2
|
-
// option's `icon`
|
|
1
|
+
// The vue segmented control with NuxtLink under its `link` part, an
|
|
2
|
+
// option's `icon` before its label, and the options' text resolved.
|
|
3
3
|
import Core from "@zoobzio/vue/components/segmented-control.vue";
|
|
4
4
|
|
|
5
5
|
import NuxtLink from "#app/components/nuxt-link";
|
|
6
6
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
7
|
import { iconOf } from "./icon";
|
|
8
|
+
import { texts } from "./text";
|
|
8
9
|
|
|
9
10
|
export default wrap(Core, {
|
|
11
|
+
props: (props) => ({ ...props, options: texts(props.options) }),
|
|
10
12
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
11
13
|
slots: { itemPrepend: ({ option }) => iconOf(option.icon) },
|
|
12
14
|
});
|
package/app/components/select.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
// The vue select with the `expand` icon after its display
|
|
1
|
+
// The vue select with the `expand` icon after its display, and its text —
|
|
2
|
+
// the options, the selection, the placeholder — resolved.
|
|
2
3
|
import Core from "@zoobzio/vue/components/select.vue";
|
|
3
4
|
|
|
4
5
|
import { icon } from "./icon";
|
|
6
|
+
import { textOr, texts } from "./text";
|
|
5
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
8
|
|
|
7
9
|
export default wrap(Core, {
|
|
10
|
+
props: (props) => ({
|
|
11
|
+
...props,
|
|
12
|
+
options: texts(props.options),
|
|
13
|
+
modelValue: texts(props.modelValue),
|
|
14
|
+
placeholder: textOr(props.placeholder, "select.placeholder"),
|
|
15
|
+
}),
|
|
8
16
|
slots: { triggerAppend: () => [icon("expand")] },
|
|
9
17
|
});
|
package/app/components/table.ts
CHANGED
|
@@ -7,8 +7,14 @@
|
|
|
7
7
|
// Its Fab slots draw the `refresh`, `columns`, and `actions` icons; the
|
|
8
8
|
// head draws `drag` on each handle, a column's own `icon` before its
|
|
9
9
|
// header, and `sort-asc` or `sort-desc` after a sorted header; a bulk action
|
|
10
|
-
// draws its own `icon`.
|
|
11
|
-
|
|
10
|
+
// draws its own `icon`. Its own text — the toolbar's labels and
|
|
11
|
+
// placeholders, the empty state, the clear button — reads in the
|
|
12
|
+
// visitor's locale, and a date, number, currency, file size or boolean
|
|
13
|
+
// cell formats through the app's prosary service.
|
|
14
|
+
import type {
|
|
15
|
+
TableBodyPassthrough,
|
|
16
|
+
TableCellContext,
|
|
17
|
+
} from "@zoobzio/vue/types/components/table-body";
|
|
12
18
|
import type { TableColumnsPassthrough } from "@zoobzio/vue/types/components/table-columns";
|
|
13
19
|
import type { TableHeadPassthrough } from "@zoobzio/vue/types/components/table-head";
|
|
14
20
|
|
|
@@ -23,11 +29,18 @@ import Menu from "./menu";
|
|
|
23
29
|
import Pagination from "./pagination";
|
|
24
30
|
import TableSearch from "./table-search";
|
|
25
31
|
import { icon, iconOf, iconPart } from "./icon";
|
|
32
|
+
import { cellSlots } from "./cell";
|
|
33
|
+
import { text, textSlot } from "./text";
|
|
26
34
|
|
|
27
35
|
export default wrap(Core, {
|
|
28
36
|
pt: (pt) => ({
|
|
29
37
|
...pt,
|
|
30
|
-
search: {
|
|
38
|
+
search: {
|
|
39
|
+
as: TableSearch,
|
|
40
|
+
placeholder: text("table.search"),
|
|
41
|
+
...pt?.search,
|
|
42
|
+
},
|
|
43
|
+
refresh: { label: text("table.refresh"), ...pt?.refresh },
|
|
31
44
|
pagination: { as: Pagination, ...pt?.pagination },
|
|
32
45
|
head: layer<TableHeadPassthrough>(pt?.head, {
|
|
33
46
|
selectAllCheckbox: { as: Checkbox },
|
|
@@ -35,13 +48,16 @@ export default wrap(Core, {
|
|
|
35
48
|
body: layer<TableBodyPassthrough<unknown>>(pt?.body, {
|
|
36
49
|
link: () => ({ as: NuxtLink }),
|
|
37
50
|
rowCheckbox: { as: Checkbox },
|
|
51
|
+
actionsTrigger: { label: text("table.actions") },
|
|
38
52
|
actionsMenu: { as: Menu },
|
|
39
53
|
}),
|
|
40
54
|
columns: layer<TableColumnsPassthrough>(pt?.columns, {
|
|
41
|
-
|
|
55
|
+
trigger: { label: text("table.columns") },
|
|
56
|
+
command: { as: Command, placeholder: text("table.searchColumns") },
|
|
42
57
|
}),
|
|
43
58
|
}),
|
|
44
59
|
slots: {
|
|
60
|
+
...cellSlots<TableCellContext<unknown>>(({ table }) => table.currency),
|
|
45
61
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
46
62
|
columns: ({ settings }) => iconPart(settings.trigger, "columns"),
|
|
47
63
|
actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
|
|
@@ -52,5 +68,7 @@ export default wrap(Core, {
|
|
|
52
68
|
? [icon(table.sortDirection === "asc" ? "sort-asc" : "sort-desc")]
|
|
53
69
|
: [],
|
|
54
70
|
bulkActionPrepend: ({ action }) => iconOf(action.icon),
|
|
71
|
+
bulkClear: () => textSlot("table.clear"),
|
|
72
|
+
empty: () => textSlot("table.empty"),
|
|
55
73
|
},
|
|
56
74
|
});
|
package/app/components/tabs.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// The vue tabs with NuxtLink under its `link` part
|
|
2
|
-
//
|
|
1
|
+
// The vue tabs with NuxtLink under its `link` part, a tab's `icon` before
|
|
2
|
+
// its label, and the tabs' text resolved.
|
|
3
3
|
import Core from "@zoobzio/vue/components/tabs.vue";
|
|
4
4
|
|
|
5
5
|
import NuxtLink from "#app/components/nuxt-link";
|
|
6
6
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
7
|
import { iconOf } from "./icon";
|
|
8
|
+
import { texts } from "./text";
|
|
8
9
|
|
|
9
10
|
export default wrap(Core, {
|
|
11
|
+
props: (props) => ({ ...props, tabs: texts(props.tabs) }),
|
|
10
12
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
11
13
|
slots: { triggerPrepend: ({ option }) => iconOf(option.icon) },
|
|
12
14
|
});
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
// The vue tags input with the `remove` icon
|
|
1
|
+
// The vue tags input with the `remove` icon on each tag, and its
|
|
2
|
+
// placeholder resolved.
|
|
2
3
|
import Core from "@zoobzio/vue/components/tags-input.vue";
|
|
3
4
|
|
|
4
5
|
import { icon } from "./icon";
|
|
6
|
+
import { textOr } from "./text";
|
|
5
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
8
|
|
|
7
9
|
export default wrap(Core, {
|
|
10
|
+
props: (props) => ({
|
|
11
|
+
...props,
|
|
12
|
+
placeholder: textOr(props.placeholder, "tagsInput.placeholder"),
|
|
13
|
+
}),
|
|
8
14
|
slots: { itemDeletePrepend: () => [icon("remove")] },
|
|
9
15
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The text glue of the wrappers: a text, or the texts of a value, resolved
|
|
2
|
+
// through the app's prosary service as `icon.ts` draws through the app's
|
|
3
|
+
// sprite. Each runs at render time — in a slot default, a `pt` function or
|
|
4
|
+
// a `props` map — where the Nuxt app is reachable from the rendering
|
|
5
|
+
// instance, and where what it reads of the service's locale and messages
|
|
6
|
+
// is tracked. Never call one at module scope.
|
|
7
|
+
import type { Contract } from "#build/prosary/index.mjs";
|
|
8
|
+
import type { PrimitiveProps } from "@zoobzio/vue/types/components/primitive";
|
|
9
|
+
import type { Text } from "@zoobzio/kit";
|
|
10
|
+
import type { Format } from "prosary";
|
|
11
|
+
import type { VNode } from "vue";
|
|
12
|
+
|
|
13
|
+
import { useNuxtApp } from "#app";
|
|
14
|
+
import { createTextVNode, h } from "vue";
|
|
15
|
+
import { resolveText, resolveTexts } from "../utils/text";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One text as the visitor reads it, called as `$t` is: a key and its
|
|
19
|
+
* values — `text("pagination.info", { page, count, total })` — or a
|
|
20
|
+
* message held as data, formatted in the active locale. A plain string
|
|
21
|
+
* the contract does not declare stands as it is.
|
|
22
|
+
*/
|
|
23
|
+
export const text: Format<Contract> & ((value: Text) => string) = (
|
|
24
|
+
value: unknown,
|
|
25
|
+
...args: unknown[]
|
|
26
|
+
): string =>
|
|
27
|
+
resolveText(useNuxtApp().$prosary, args.length ? [value, ...args] : value);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A value with every text in it resolved: the options, groups, items or
|
|
31
|
+
* nodes a wrapper hands on to the component it wraps.
|
|
32
|
+
*/
|
|
33
|
+
export const texts = <T>(value: T): T =>
|
|
34
|
+
resolveTexts(useNuxtApp().$prosary, value);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* One text as a slot's content: what a slot default returns where the
|
|
38
|
+
* component's own default is its English.
|
|
39
|
+
*/
|
|
40
|
+
export const textSlot = (value: Text): VNode[] => [
|
|
41
|
+
createTextVNode(text(value)),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A text that may be absent: resolved when given, absent otherwise, so the
|
|
46
|
+
* component's own default applies.
|
|
47
|
+
*/
|
|
48
|
+
export const textIf = (value: Text | undefined): string | undefined =>
|
|
49
|
+
value === undefined ? undefined : text(value);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A text that may be absent: resolved when given, the fallback message
|
|
53
|
+
* otherwise. For a prop the component defaults in English, so the layer's
|
|
54
|
+
* default reads in the visitor's locale instead.
|
|
55
|
+
*/
|
|
56
|
+
export const textOr = (value: Text | undefined, fallback: Text): string =>
|
|
57
|
+
text(value ?? fallback);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A rendered part with some of its props replaced: the default of a slot
|
|
61
|
+
* that replaces a part whose text the wrapper resolves. The part's resolved
|
|
62
|
+
* `settings` carry `as` and the props, as the vue template hands them to
|
|
63
|
+
* its `Primitive`.
|
|
64
|
+
*/
|
|
65
|
+
export const textPart = (
|
|
66
|
+
settings: PrimitiveProps & Record<string, unknown>,
|
|
67
|
+
over: Record<string, unknown>,
|
|
68
|
+
): VNode[] => {
|
|
69
|
+
const { as, ...props } = settings;
|
|
70
|
+
return [h(as, { ...props, ...over })];
|
|
71
|
+
};
|
package/app/components/toast.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
// The vue toast with the `close` icon before its close
|
|
1
|
+
// The vue toast with the `close` icon before its close, and its title and
|
|
2
|
+
// description resolved.
|
|
2
3
|
import Core from "@zoobzio/vue/components/toast.vue";
|
|
3
4
|
|
|
4
5
|
import { icon } from "./icon";
|
|
6
|
+
import { textIf } from "./text";
|
|
5
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
8
|
|
|
7
9
|
export default wrap(Core, {
|
|
10
|
+
props: (props) => ({
|
|
11
|
+
...props,
|
|
12
|
+
title: textIf(props.title),
|
|
13
|
+
description: textIf(props.description),
|
|
14
|
+
}),
|
|
8
15
|
slots: { closePrepend: () => [icon("close")] },
|
|
9
16
|
});
|
package/app/components/tree.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// The vue tree with NuxtLink under its `link` part
|
|
2
|
-
// the
|
|
1
|
+
// The vue tree with NuxtLink under its `link` part, `expand` as the toggle
|
|
2
|
+
// of a node with children, and the nodes' text resolved at every depth.
|
|
3
3
|
import Core from "@zoobzio/vue/components/tree.vue";
|
|
4
4
|
|
|
5
5
|
import NuxtLink from "#app/components/nuxt-link";
|
|
6
6
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
7
|
import { icon } from "./icon";
|
|
8
|
+
import { texts } from "./text";
|
|
8
9
|
|
|
9
10
|
export default wrap(Core, {
|
|
11
|
+
props: (props) => ({ ...props, items: texts(props.items) }),
|
|
10
12
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
11
13
|
slots: {
|
|
12
14
|
itemToggle: ({ item }) => (item.hasChildren ? [icon("expand")] : []),
|
|
@@ -2,7 +2,7 @@ import type { AppError } from "../types/error";
|
|
|
2
2
|
import type { RequestOptions } from "../types/request";
|
|
3
3
|
import type { MaybeRefOrGetter } from "vue";
|
|
4
4
|
|
|
5
|
-
import { useAsyncData, useLazyAsyncData } from "#app";
|
|
5
|
+
import { useAsyncData, useLazyAsyncData, useNuxtApp } from "#app";
|
|
6
6
|
import { toValue, watch } from "vue";
|
|
7
7
|
import { status } from "ltrl-http";
|
|
8
8
|
import { useLogger } from "./log";
|
|
@@ -25,6 +25,9 @@ const make = (
|
|
|
25
25
|
) => {
|
|
26
26
|
const id = crypto.randomUUID();
|
|
27
27
|
const log = useLogger(toValue(key));
|
|
28
|
+
// The error's message and the notification's title are strings, so the
|
|
29
|
+
// defaults resolve here, in the locale active when the request fails.
|
|
30
|
+
const { $t: t } = useNuxtApp();
|
|
28
31
|
|
|
29
32
|
log.debug("Request started", {
|
|
30
33
|
id,
|
|
@@ -49,10 +52,10 @@ const make = (
|
|
|
49
52
|
});
|
|
50
53
|
throw useAppError(
|
|
51
54
|
errOpts?.status ?? status.INTERNAL_SERVER_ERROR,
|
|
52
|
-
errOpts?.message ?? "
|
|
55
|
+
errOpts?.message ?? t("request.failed"),
|
|
53
56
|
{
|
|
54
57
|
notification: errOpts?.notification ?? {
|
|
55
|
-
title: "
|
|
58
|
+
title: t("request.unknown"),
|
|
56
59
|
variant: "error",
|
|
57
60
|
description: results.error.value?.message,
|
|
58
61
|
},
|
package/app/constants/editor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IconAlias } from "../types/icon";
|
|
2
|
+
import type { AppMessage } from "../types/text";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The icon of each editor tool, by the tool's key: the marks, the blocks,
|
|
@@ -21,3 +22,23 @@ export const EDITOR_TOOL_ICONS: Readonly<Record<string, IconAlias>> = {
|
|
|
21
22
|
undo: "undo",
|
|
22
23
|
redo: "redo",
|
|
23
24
|
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The message of each editor tool's label, by the tool's key: the marks,
|
|
28
|
+
* the blocks, and history. A heading tool is not here: its message takes
|
|
29
|
+
* the level its key carries, which `toolText` reads.
|
|
30
|
+
*/
|
|
31
|
+
export const EDITOR_TOOL_TEXT: Readonly<Record<string, AppMessage>> = {
|
|
32
|
+
bold: "editor.bold",
|
|
33
|
+
italic: "editor.italic",
|
|
34
|
+
underline: "editor.underline",
|
|
35
|
+
strike: "editor.strike",
|
|
36
|
+
code: "editor.code",
|
|
37
|
+
bulletList: "editor.bulletList",
|
|
38
|
+
orderedList: "editor.orderedList",
|
|
39
|
+
blockquote: "editor.blockquote",
|
|
40
|
+
codeBlock: "editor.codeBlock",
|
|
41
|
+
horizontalRule: "editor.rule",
|
|
42
|
+
undo: "editor.undo",
|
|
43
|
+
redo: "editor.redo",
|
|
44
|
+
};
|
package/app/error.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { NuxtError } from "#app";
|
|
3
3
|
|
|
4
|
-
import { clearError } from "#app";
|
|
4
|
+
import { clearError, useNuxtApp } from "#app";
|
|
5
5
|
import { computed } from "vue";
|
|
6
6
|
import {
|
|
7
7
|
ERROR_DEFAULT_STATUS_CODE,
|
|
@@ -14,14 +14,16 @@ const props = defineProps<{
|
|
|
14
14
|
error: NuxtError;
|
|
15
15
|
}>();
|
|
16
16
|
|
|
17
|
+
const { $t: t } = useNuxtApp();
|
|
18
|
+
|
|
17
19
|
const statusCode = computed(
|
|
18
20
|
() => props.error.statusCode ?? ERROR_DEFAULT_STATUS_CODE,
|
|
19
21
|
);
|
|
20
22
|
|
|
21
23
|
const message = computed(() => {
|
|
22
24
|
if (statusCode.value === ERROR_NOT_FOUND_STATUS_CODE)
|
|
23
|
-
return "
|
|
24
|
-
return props.error.message || "
|
|
25
|
+
return t("error.notFound");
|
|
26
|
+
return props.error.message || t("error.unknown");
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
const handleError = () => clearError({ redirect: "/" });
|
|
@@ -31,6 +33,8 @@ const handleError = () => clearError({ redirect: "/" });
|
|
|
31
33
|
<div class="f-error-page">
|
|
32
34
|
<span class="f-error-code">{{ statusCode }}</span>
|
|
33
35
|
<span class="f-error-message">{{ message }}</span>
|
|
34
|
-
<button class="f-error-action" @click="handleError">
|
|
36
|
+
<button class="f-error-action" @click="handleError">
|
|
37
|
+
{{ t("error.home") }}
|
|
38
|
+
</button>
|
|
35
39
|
</div>
|
|
36
40
|
</template>
|
package/app/factories/browser.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { useNuxtApp } from "#app";
|
|
|
5
5
|
import { BrowserService } from "@zoobzio/browser";
|
|
6
6
|
import { accessBrowser } from "../stores/browser";
|
|
7
7
|
import { split } from "../utils/actions";
|
|
8
|
+
import { resolveTexts } from "../utils/text";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Builds the id-scoped composable of a browser. Call it at module scope:
|
|
@@ -12,9 +13,10 @@ import { split } from "../utils/actions";
|
|
|
12
13
|
* the wiring (the fetch and the handlers), and `id` keys everything that
|
|
13
14
|
* follows. Each call of the composable, in setup, builds a service over
|
|
14
15
|
* the id's shared store and relays its domain events onto the app logger and the Nuxt hook
|
|
15
|
-
* bus as `browser:updated` and `browser:navigated`. The
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* bus as `browser:updated` and `browser:navigated`. The columns' and the
|
|
17
|
+
* actions' labels resolve through the app's prosary service as the service
|
|
18
|
+
* is built. The machine itself is `@zoobzio/browser`; the Vue browser
|
|
19
|
+
* renders it through its `service` prop.
|
|
18
20
|
*/
|
|
19
21
|
export const createBrowser = <T>(
|
|
20
22
|
id: string,
|
|
@@ -40,8 +42,15 @@ export const createBrowser = <T>(
|
|
|
40
42
|
return (): Service<T> => {
|
|
41
43
|
const nuxt = useNuxtApp();
|
|
42
44
|
const log = nuxt.$logger(id);
|
|
45
|
+
const resolved: Config<T> = {
|
|
46
|
+
...config,
|
|
47
|
+
columns: resolveTexts(nuxt.$prosary, config.columns),
|
|
48
|
+
actions: resolveTexts(nuxt.$prosary, config.actions),
|
|
49
|
+
folderActions: resolveTexts(nuxt.$prosary, config.folderActions),
|
|
50
|
+
bulkActions: resolveTexts(nuxt.$prosary, config.bulkActions),
|
|
51
|
+
};
|
|
43
52
|
const state = accessBrowser<T>(id, initial);
|
|
44
|
-
const service = new BrowserService(id,
|
|
53
|
+
const service = new BrowserService(id, resolved, state, wiring);
|
|
45
54
|
service.on("updated", (event) => {
|
|
46
55
|
log.debug("Browser updated", event);
|
|
47
56
|
nuxt.callHook("browser:updated", event);
|
package/app/factories/form.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Actions, Service } from "@zoobzio/form";
|
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
5
|
import { FormService } from "@zoobzio/form";
|
|
6
6
|
import { accessForm } from "../stores/form";
|
|
7
|
+
import { resolveTexts } from "../utils/text";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Builds the id-scoped composable of a form. Call it at module scope: the
|
|
@@ -11,8 +12,10 @@ import { accessForm } from "../stores/form";
|
|
|
11
12
|
* lifecycle actions and the middleware), and `id` keys everything that
|
|
12
13
|
* follows. Each call of the composable, in setup, builds a service over
|
|
13
14
|
* the id's shared store and relays its domain events onto the app logger and the Nuxt hook
|
|
14
|
-
* bus under the `form:` prefix. The
|
|
15
|
-
*
|
|
15
|
+
* bus under the `form:` prefix. The fields' text — each label, hint,
|
|
16
|
+
* placeholder and option — resolves through the app's prosary service as
|
|
17
|
+
* the service is built. The machine itself is `@zoobzio/form`; the Vue
|
|
18
|
+
* form renders it through its `service` prop.
|
|
16
19
|
*/
|
|
17
20
|
export const createForm = <T>(
|
|
18
21
|
id: string,
|
|
@@ -23,8 +26,12 @@ export const createForm = <T>(
|
|
|
23
26
|
return (): Service<T> => {
|
|
24
27
|
const nuxt = useNuxtApp();
|
|
25
28
|
const log = nuxt.$logger(id);
|
|
26
|
-
const
|
|
27
|
-
|
|
29
|
+
const resolved = {
|
|
30
|
+
...config,
|
|
31
|
+
fields: resolveTexts(nuxt.$prosary, config.fields),
|
|
32
|
+
};
|
|
33
|
+
const state = accessForm(id, resolved, initial);
|
|
34
|
+
const service = new FormService(id, resolved, state, wiring);
|
|
28
35
|
service.on("initialized", (event) => {
|
|
29
36
|
log.debug("Form initialized", event);
|
|
30
37
|
nuxt.callHook("form:initialized", event);
|