@zoobzio/nuxt 0.1.2 → 0.1.4

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 +67 -1
  2. package/app/app.d.ts +14 -0
  3. package/app/app.vue +4 -8
  4. package/app/components/accordion.ts +4 -2
  5. package/app/components/autocomplete.ts +6 -10
  6. package/app/components/breadcrumb.ts +11 -3
  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 +19 -1
  11. package/app/components/date-filters.ts +46 -9
  12. package/app/components/dialog.ts +13 -0
  13. package/app/components/directory.ts +10 -3
  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 +16 -3
  18. package/app/components/form.ts +20 -2
  19. package/app/components/hero.ts +7 -1
  20. package/app/components/keywords.ts +35 -8
  21. package/app/components/listbox.ts +9 -0
  22. package/app/components/menu.ts +8 -3
  23. package/app/components/multi-select.ts +24 -3
  24. package/app/components/pagination.ts +33 -3
  25. package/app/components/radio.ts +11 -0
  26. package/app/components/rich-text.ts +8 -4
  27. package/app/components/segmented-control.ts +8 -3
  28. package/app/components/select.ts +13 -2
  29. package/app/components/table.ts +22 -4
  30. package/app/components/tabs.ts +7 -3
  31. package/app/components/tags-input.ts +7 -1
  32. package/app/components/text.ts +74 -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 +9 -2
  39. package/app/factories/form.ts +15 -6
  40. package/app/factories/table.ts +17 -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 +93 -0
  45. package/modules/imports/constant.ts +8 -1
  46. package/nuxt.config.ts +3 -1
  47. package/package.json +14 -10
@@ -1,8 +1,10 @@
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 in the visitor's locale: its label and hint through their
3
+ // slots, its placeholder — an attribute of the input — through the field,
4
+ // and its options through the Select, MultiSelect and Radio of the layer.
4
5
  import Core from "@zoobzio/vue/components/form-field.vue";
5
6
 
7
+ import { text, textSlot } from "./text";
6
8
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
9
  import Checkbox from "./checkbox";
8
10
  import DatePicker from "./date-picker";
@@ -13,6 +15,13 @@ import Select from "./select";
13
15
  import TagsInput from "./tags-input";
14
16
 
15
17
  export default wrap(Core, {
18
+ props: (props) => ({
19
+ ...props,
20
+ field:
21
+ "placeholder" in props.field && props.field.placeholder !== undefined
22
+ ? { ...props.field, placeholder: text(props.field.placeholder) }
23
+ : props.field,
24
+ }),
16
25
  pt: {
17
26
  select: { as: Select },
18
27
  multiSelect: { as: MultiSelect },
@@ -22,4 +31,8 @@ export default wrap(Core, {
22
31
  fileInput: { as: FileInput },
23
32
  richText: { as: RichText },
24
33
  },
34
+ slots: {
35
+ labelText: ({ field }) => textSlot(field.label),
36
+ hintText: ({ field }) => (field.hint ? textSlot(field.hint) : []),
37
+ },
25
38
  });
@@ -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,15 @@
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
+ // its action's label in the visitor's locale.
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, textSlot } from "./text";
6
8
 
7
9
  export default wrap(Core, {
10
+ props: (props) => ({ ...props, description: textIf(props.description) }),
8
11
  pt: { link: { as: NuxtLink } },
12
+ slots: {
13
+ actionLabel: ({ action }) => (action ? textSlot(action.label) : []),
14
+ },
9
15
  });
@@ -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 each item's label in the visitor's locale.
2
+ import Core from "@zoobzio/vue/components/listbox.vue";
3
+
4
+ import { textSlot } from "./text";
5
+ import { wrap } from "@zoobzio/vue/utils/wrap";
6
+
7
+ export default wrap(Core, {
8
+ slots: { itemLabel: ({ item }) => textSlot(item.label) },
9
+ });
@@ -1,17 +1,22 @@
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 trigger's label, the groups' and the
3
+ // items' — in the visitor's locale.
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, textIn } from "./text";
10
11
 
11
12
  export default wrap(Core, {
13
+ props: (props) => ({ ...props, label: textIf(props.label) }),
12
14
  pt: { link: () => ({ as: NuxtLink }) },
13
15
  slots: {
16
+ groupLabel: ({ group }) =>
17
+ group.label ? textIn("div", "f-caption", group.label) : [],
14
18
  itemPrepend: ({ item }) =>
15
19
  item.icon ? [h(Icon, { name: item.icon })] : [],
20
+ itemLabel: ({ item }) => textIn("span", "f-span", item.label),
16
21
  },
17
22
  });
@@ -1,12 +1,33 @@
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 items,
3
+ // the selection, the placeholder — in the visitor's locale.
3
4
  import Core from "@zoobzio/vue/components/multi-select.vue";
4
5
 
6
+ import { SELECT_TRUNCATE } from "@zoobzio/vue/constants/selection";
5
7
  import { icon } from "./icon";
8
+ import { text, textIn, textOr, textSlot } from "./text";
6
9
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
10
  import Checkbox from "./checkbox";
8
11
 
9
12
  export default wrap(Core, {
13
+ props: (props) => ({
14
+ ...props,
15
+ placeholder: textOr(props.placeholder, "select.multiple"),
16
+ }),
10
17
  pt: { itemCheckbox: () => ({ as: Checkbox }) },
11
- slots: { triggerAppend: () => [icon("expand")] },
18
+ slots: {
19
+ triggerLabel: ({ modelValue, placeholder }) =>
20
+ textIn(
21
+ "span",
22
+ "f-span",
23
+ modelValue.value?.length
24
+ ? modelValue.value
25
+ .slice(0, SELECT_TRUNCATE)
26
+ .map((item) => text(item.label))
27
+ .join(", ")
28
+ : placeholder,
29
+ ),
30
+ itemLabel: ({ item }) => textSlot(item.label),
31
+ triggerAppend: () => [icon("expand")],
32
+ },
12
33
  });
@@ -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,11 @@
1
+ // The vue radio with each option's label in the visitor's locale.
2
+ import Core from "@zoobzio/vue/components/radio.vue";
3
+
4
+ import { textIn } from "./text";
5
+ import { wrap } from "@zoobzio/vue/utils/wrap";
6
+
7
+ export default wrap(Core, {
8
+ slots: {
9
+ optionLabel: ({ option }) => textIn("span", "f-span", option.label),
10
+ },
11
+ });
@@ -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,17 @@
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 each label in the visitor's locale.
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 { textIn } from "./text";
8
9
 
9
10
  export default wrap(Core, {
10
11
  pt: { link: () => ({ as: NuxtLink }) },
11
- slots: { itemPrepend: ({ option }) => iconOf(option.icon) },
12
+ slots: {
13
+ itemPrepend: ({ option }) => iconOf(option.icon),
14
+ itemLabel: ({ option }) =>
15
+ option.label ? textIn("span", "f-span", option.label) : [],
16
+ },
12
17
  });
@@ -1,9 +1,20 @@
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 — in the visitor's locale.
2
3
  import Core from "@zoobzio/vue/components/select.vue";
3
4
 
4
5
  import { icon } from "./icon";
6
+ import { textIn, textOr, textSlot } from "./text";
5
7
  import { wrap } from "@zoobzio/vue/utils/wrap";
6
8
 
7
9
  export default wrap(Core, {
8
- slots: { triggerAppend: () => [icon("expand")] },
10
+ props: (props) => ({
11
+ ...props,
12
+ placeholder: textOr(props.placeholder, "select.placeholder"),
13
+ }),
14
+ slots: {
15
+ triggerLabel: ({ modelValue, placeholder }) =>
16
+ textIn("span", "f-span", modelValue.value?.label ?? placeholder),
17
+ itemLabel: ({ option }) => textSlot(option.label),
18
+ triggerAppend: () => [icon("expand")],
19
+ },
9
20
  });
@@ -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,16 @@
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 each label in the visitor's locale.
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 { textSlot } from "./text";
8
9
 
9
10
  export default wrap(Core, {
10
11
  pt: { link: () => ({ as: NuxtLink }) },
11
- slots: { triggerPrepend: ({ option }) => iconOf(option.icon) },
12
+ slots: {
13
+ triggerPrepend: ({ option }) => iconOf(option.icon),
14
+ triggerLabel: ({ option }) => textSlot(option.label),
15
+ },
12
16
  });
@@ -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,74 @@
1
+ // The text glue of the wrappers: one text resolved through the app's
2
+ // prosary service as `icon.ts` draws through the app's sprite. A wrapper
3
+ // resolves a label where the component renders it, in the default of the
4
+ // component's text slot, and a scalar text prop the component hands to an
5
+ // attribute — a placeholder, an accessible name — in its `props` map. Each
6
+ // runs at render time, where the Nuxt app is reachable from the rendering
7
+ // instance, and where what it reads of the service's locale and messages
8
+ // is tracked. Never call one at module scope.
9
+ import type { Contract } from "#build/prosary/index.mjs";
10
+ import type { PrimitiveProps } from "@zoobzio/vue/types/components/primitive";
11
+ import type { Text } from "@zoobzio/kit";
12
+ import type { Format } from "prosary";
13
+ import type { VNode } from "vue";
14
+
15
+ import { useNuxtApp } from "#app";
16
+ import { createTextVNode, h } from "vue";
17
+ import { resolveText } from "../utils/text";
18
+
19
+ /**
20
+ * One text as the visitor reads it, called as `$t` is: a key and its
21
+ * values — `text("pagination.info", { page, count, total })` — or a
22
+ * message held as data, formatted in the active locale. A plain string
23
+ * the contract does not declare stands as it is.
24
+ */
25
+ export const text: Format<Contract> & ((value: Text) => string) = (
26
+ value: unknown,
27
+ ...args: unknown[]
28
+ ): string =>
29
+ resolveText(useNuxtApp().$prosary, args.length ? [value, ...args] : value);
30
+
31
+ /**
32
+ * One text as a slot's content: what a slot default returns where the
33
+ * component's own default is its English.
34
+ */
35
+ export const textSlot = (value: Text): VNode[] => [
36
+ createTextVNode(text(value)),
37
+ ];
38
+
39
+ /**
40
+ * One text inside an element: the span or caption a component's own slot
41
+ * default renders around a label, with the text in the visitor's locale.
42
+ */
43
+ export const textIn = (tag: string, cls: string, value: Text): VNode[] => [
44
+ h(tag, { class: cls }, text(value)),
45
+ ];
46
+
47
+ /**
48
+ * A text that may be absent: resolved when given, absent otherwise, so the
49
+ * component's own default applies.
50
+ */
51
+ export const textIf = (value: Text | undefined): string | undefined =>
52
+ value === undefined ? undefined : text(value);
53
+
54
+ /**
55
+ * A text that may be absent: resolved when given, the fallback message
56
+ * otherwise. For a prop the component defaults in English, so the layer's
57
+ * default reads in the visitor's locale instead.
58
+ */
59
+ export const textOr = (value: Text | undefined, fallback: Text): string =>
60
+ text(value ?? fallback);
61
+
62
+ /**
63
+ * A rendered part with some of its props replaced: the default of a slot
64
+ * that replaces a part whose text the wrapper resolves. The part's resolved
65
+ * `settings` carry `as` and the props, as the vue template hands them to
66
+ * its `Primitive`.
67
+ */
68
+ export const textPart = (
69
+ settings: PrimitiveProps & Record<string, unknown>,
70
+ over: Record<string, unknown>,
71
+ ): VNode[] => {
72
+ const { as, ...props } = settings;
73
+ return [h(as, { ...props, ...over })];
74
+ };
@@ -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,14 +1,16 @@
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 each node's label in the visitor's locale.
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 { textSlot } from "./text";
8
9
 
9
10
  export default wrap(Core, {
10
11
  pt: { link: () => ({ as: NuxtLink }) },
11
12
  slots: {
12
13
  itemToggle: ({ item }) => (item.hasChildren ? [icon("expand")] : []),
14
+ itemText: ({ item }) => textSlot(item.value.label),
13
15
  },
14
16
  });
@@ -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
+ };