@zoobzio/nuxt 0.1.1 → 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.
Files changed (47) hide show
  1. package/README.md +68 -6
  2. package/app/app.d.ts +20 -2
  3. package/app/app.vue +4 -8
  4. package/app/components/accordion.ts +4 -2
  5. package/app/components/autocomplete.ts +8 -11
  6. package/app/components/breadcrumb.ts +8 -2
  7. package/app/components/browser.ts +30 -6
  8. package/app/components/cell.ts +101 -0
  9. package/app/components/code.ts +28 -0
  10. package/app/components/command.ts +10 -1
  11. package/app/components/date-filters.ts +42 -9
  12. package/app/components/dialog.ts +13 -0
  13. package/app/components/directory.ts +4 -2
  14. package/app/components/editor.ts +8 -4
  15. package/app/components/fab.ts +9 -0
  16. package/app/components/facets.ts +14 -4
  17. package/app/components/form-field.ts +4 -3
  18. package/app/components/form.ts +20 -2
  19. package/app/components/hero.ts +8 -1
  20. package/app/components/keywords.ts +35 -8
  21. package/app/components/listbox.ts +9 -0
  22. package/app/components/menu.ts +9 -3
  23. package/app/components/multi-select.ts +10 -2
  24. package/app/components/pagination.ts +33 -3
  25. package/app/components/radio.ts +9 -0
  26. package/app/components/rich-text.ts +8 -4
  27. package/app/components/segmented-control.ts +4 -2
  28. package/app/components/select.ts +9 -1
  29. package/app/components/table.ts +22 -4
  30. package/app/components/tabs.ts +4 -2
  31. package/app/components/tags-input.ts +7 -1
  32. package/app/components/text.ts +71 -0
  33. package/app/components/toast.ts +8 -1
  34. package/app/components/tree.ts +4 -2
  35. package/app/composables/request.ts +6 -3
  36. package/app/constants/editor.ts +21 -0
  37. package/app/error.vue +8 -4
  38. package/app/factories/browser.ts +13 -4
  39. package/app/factories/form.ts +11 -4
  40. package/app/factories/table.ts +15 -4
  41. package/app/plugins/locale.ts +19 -0
  42. package/app/types/text.ts +12 -0
  43. package/app/utils/editor.ts +14 -1
  44. package/app/utils/text.ts +90 -0
  45. package/modules/imports/constant.ts +8 -1
  46. package/nuxt.config.ts +3 -1
  47. package/package.json +14 -10
@@ -1,13 +1,23 @@
1
- // The vue facets with the `filter` icon as the content of its trigger and
2
- // the layer's Command behind it, so a facet's `icon` draws before its
3
- // label.
1
+ // The vue facets with the layer's Command behind its popover, the `filter`
2
+ // icon as its trigger's content, and its text — the trigger, the groups and
3
+ // their items, the placeholder — resolved.
4
4
  import Core from "@zoobzio/vue/components/facets.vue";
5
5
 
6
6
  import { iconPart } from "./icon";
7
+ import { text, textOr, texts } from "./text";
7
8
  import { wrap } from "@zoobzio/vue/utils/wrap";
8
9
  import Command from "./command";
9
10
 
10
11
  export default wrap(Core, {
11
- pt: { command: { as: Command } },
12
+ props: (props) => ({
13
+ ...props,
14
+ groups: texts(props.groups),
15
+ placeholder: textOr(props.placeholder, "facets.placeholder"),
16
+ }),
17
+ pt: (pt) => ({
18
+ ...pt,
19
+ trigger: { label: text("facets.trigger"), ...pt?.trigger },
20
+ command: { as: Command, ...pt?.command },
21
+ }),
12
22
  slots: { trigger: ({ settings }) => iconPart(settings.trigger, "filter") },
13
23
  });
@@ -1,8 +1,8 @@
1
- // The vue form field with the layer's wrapped controls behind its parts, so
2
- // a field's select, multi select, checkbox, date picker, tags input, file
3
- // input, and rich text draw their icons.
1
+ // The vue form field with the layer's inputs behind its parts, and the
2
+ // field's text — its label, hint, placeholder, options — resolved.
4
3
  import Core from "@zoobzio/vue/components/form-field.vue";
5
4
 
5
+ import { texts } from "./text";
6
6
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
7
  import Checkbox from "./checkbox";
8
8
  import DatePicker from "./date-picker";
@@ -13,6 +13,7 @@ import Select from "./select";
13
13
  import TagsInput from "./tags-input";
14
14
 
15
15
  export default wrap(Core, {
16
+ props: (props) => ({ ...props, field: texts(props.field) }),
16
17
  pt: {
17
18
  select: { as: Select },
18
19
  multiSelect: { as: MultiSelect },
@@ -1,10 +1,28 @@
1
- // The vue form with the layer's FormField rendering each field, so every
2
- // control draws its icons.
1
+ // The vue form with the layer's FormField rendering each field, and its
2
+ // footer — the reset and submit buttons — in the visitor's locale.
3
3
  import Core from "@zoobzio/vue/components/form.vue";
4
4
 
5
+ import { h } from "vue";
5
6
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
+ import { text } from "./text";
6
8
  import FormField from "./form-field";
7
9
 
8
10
  export default wrap(Core, {
9
11
  pt: { field: () => ({ as: FormField }) },
12
+ slots: {
13
+ footer: ({ form, settings }) => [
14
+ h("div", { class: "f-group f-data-form-footer" }, [
15
+ h(
16
+ "button",
17
+ { class: "f-button f-data-form-reset", ...settings.reset },
18
+ text("form.reset"),
19
+ ),
20
+ h(
21
+ "button",
22
+ { class: "f-button f-data-form-submit", ...settings.submit },
23
+ text(form.submitting ? "form.submitting" : "form.submit"),
24
+ ),
25
+ ]),
26
+ ],
27
+ },
10
28
  });
@@ -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 `keywords` icon as the content of its trigger,
2
- // the layer's TagsInput behind its include and exclude inputs, and the
3
- // layer's SegmentedControl as its match control.
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
- includeInput: { as: TagsInput },
14
- excludeInput: { as: TagsInput },
15
- matchControl: { as: SegmentedControl },
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
+ });
@@ -1,14 +1,20 @@
1
- // The vue menu with NuxtLink under its `link` part, and an item's `icon`
2
- // (the field app.d.ts adds to MenuItem) drawn in the `itemPrepend` slot
3
- // unless the consumer renders that slot itself.
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 select with the `expand` icon after its display and the
2
- // layer's Checkbox rendering each item's checkbox.
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, and the layer's Select as its size
3
- // control.
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: { size: { as: Select } },
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 (`toolIcon`, by the tool's
2
- // key) before its label, as the editor draws them.
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: { toolPrepend: ({ tool }) => iconOf(toolIcon(tool.key)) },
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 and an
2
- // option's `icon` drawn before its label.
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
  });
@@ -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
  });
@@ -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
- import type { TableBodyPassthrough } from "@zoobzio/vue/types/components/table-body";
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: { as: TableSearch, ...pt?.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
- command: { as: Command },
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
  });
@@ -1,12 +1,14 @@
1
- // The vue tabs with NuxtLink under its `link` part and an option's `icon`
2
- // drawn before its label.
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 before each tag's delete label.
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
+ };
@@ -1,9 +1,16 @@
1
- // The vue toast with the `close` icon before its close label.
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
  });
@@ -1,12 +1,14 @@
1
- // The vue tree with NuxtLink under its `link` part and the `expand` icon as
2
- // the toggle of each branch.
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 ?? "Request failed",
55
+ errOpts?.message ?? t("request.failed"),
53
56
  {
54
57
  notification: errOpts?.notification ?? {
55
- title: "An unknown error occurred",
58
+ title: t("request.unknown"),
56
59
  variant: "error",
57
60
  description: results.error.value?.message,
58
61
  },
@@ -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 "The page you're looking for doesn't exist.";
24
- return props.error.message || "Something went wrong.";
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">Go home</button>
36
+ <button class="f-error-action" @click="handleError">
37
+ {{ t("error.home") }}
38
+ </button>
35
39
  </div>
36
40
  </template>