@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.
Files changed (47) hide show
  1. package/README.md +60 -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 +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
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Nuxt layer for the foundation design system. It carries the Nuxt-only
4
4
  wiring over [`@zoobzio/vue`](../vue/) and the headless services in
5
- `packages/`: `useState`-backed stores, hook-bus factories, and the app shell.
5
+ `services/`: `useState`-backed stores, hook-bus factories, and the app shell.
6
6
 
7
7
  ## Usage
8
8
 
@@ -201,6 +201,65 @@ const groups: MenuGroup[] = [
201
201
  </template>
202
202
  ```
203
203
 
204
+ ## Text
205
+
206
+ The components of `@zoobzio/vue` know nothing of translation: each renders
207
+ its text as it is, in English by default, as it does outside the layer.
208
+ The layer translates over the top, through the same `pt` layers, slot
209
+ defaults and props maps its wrappers already lay under the components.
210
+
211
+ Every `label`, `placeholder`, `title`, `description` or `hint` a component
212
+ or a service carries is a `Text` of `@zoobzio/kit`: `string`, until a layer
213
+ widens it. This layer widens it to the app's messages — a key of the app's
214
+ contract, or a key with its values — so a column, an action, a menu item,
215
+ a form field or a toast takes a message in place of a string:
216
+
217
+ ```ts
218
+ const table = createTable("users", {
219
+ columns: [
220
+ { key: "name", label: "users.column.name" },
221
+ { key: "role", label: "users.column.role" },
222
+ ],
223
+ actions: { remove: { label: "users.action.remove", action: (row) => … } },
224
+ });
225
+ ```
226
+
227
+ The layer loads [`@prosary/nuxt`](https://github.com/zoobzio/prosary) with
228
+ the build of [`@zoobzio/prose`](../../packages/prose/) — the components'
229
+ own text, as messages — as its `prosary.build`, the way it loads untheme
230
+ with `@zoobzio/theme`. An app that extends the layer gets `$t`, `useT`,
231
+ `useLocale` and `useProsary` from the module, one locale per visitor, with
232
+ no setup. An app with text of its own ships a prose package of its own — a
233
+ kit config that `extends: "@zoobzio/prose/config"`, built with
234
+ `prosary build` — and passes it as `build`; the app's option replaces the
235
+ layer's:
236
+
237
+ ```ts
238
+ export default defineNuxtConfig({
239
+ extends: ["@zoobzio/nuxt"],
240
+ prosary: { build: "@acme/prose" },
241
+ });
242
+ ```
243
+
244
+ A message resolves at the layer's boundary, before a component sees it, so
245
+ what reaches `@zoobzio/vue` is always a string:
246
+
247
+ - A wrapper's `props` map resolves what the consumer passed — the
248
+ options of a select, the groups of a menu, the nodes of a tree — and
249
+ supplies the component's own defaults (a placeholder, an empty state, a
250
+ button's name) as messages of the prose contract, through its `pt`
251
+ layer and slot defaults. The map and the defaults run on each render,
252
+ so they follow a locale switch.
253
+ - A factory resolves the labels of the columns, actions and fields it
254
+ builds a service over, once, when the service is built in setup. The
255
+ search then matches a typed prefix against a column's label as the
256
+ visitor reads it. The layer's `locale` plugin reloads the app when the
257
+ visitor switches locale, so a built service never holds a stale one.
258
+
259
+ `resolveText` and `resolveTexts` are on `#imports`, for code of the app
260
+ that renders text outside a wrapper; `AppMessage` is the message type. A string the contract does not declare — a file name, a value —
261
+ is data, and renders unchanged.
262
+
204
263
  ## Theme
205
264
 
206
265
  The components of `@zoobzio/vue` read no tokens: they are unstyled, and a
package/app/app.d.ts CHANGED
@@ -5,6 +5,20 @@ import type { FormHooks } from "./types/form";
5
5
  import type { Logger } from "./types/log";
6
6
  import type { IconAlias } from "./types/icon";
7
7
  import type { TableHooks } from "./types/table";
8
+ import type { AppMessage } from "./types/text";
9
+
10
+ // The text the packages carry admits the app's messages: a `label`,
11
+ // `placeholder` or `hint` of any service or component takes a key of the
12
+ // app's contract, or a key with its values, in place of a string. The
13
+ // contract extends @zoobzio/prose, so the components' own keys are among
14
+ // them. The layer resolves every message at its boundary — a wrapper's
15
+ // props map, a factory — so the components and the services, which know
16
+ // only strings, never see one.
17
+ declare module "@zoobzio/kit" {
18
+ interface TextMap {
19
+ app: AppMessage;
20
+ }
21
+ }
8
22
 
9
23
  // The item types of @zoobzio/vue and the action descriptors of the headless
10
24
  // packages are interfaces, so the layer widens the ones its wrappers draw
package/app/app.vue CHANGED
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { ErrorData } from "./types/error";
3
3
 
4
- import Toast from "@zoobzio/vue/components/toast.vue";
5
4
  import Toaster from "@zoobzio/vue/components/toaster.vue";
5
+ import Toast from "./components/toast";
6
6
  import {
7
7
  NuxtErrorBoundary,
8
8
  NuxtLayout,
@@ -11,7 +11,7 @@ import {
11
11
  } from "#components";
12
12
 
13
13
  import { ConfigProvider, TooltipProvider } from "reka-ui";
14
- import { isNuxtError, useHead } from "#app";
14
+ import { isNuxtError, useNuxtApp } from "#app";
15
15
  import { useId } from "vue";
16
16
  import { useNotifications } from "./composables/notification";
17
17
  </script>
@@ -19,11 +19,7 @@ import { useNotifications } from "./composables/notification";
19
19
  <script setup lang="ts">
20
20
  const useIdFunction = () => useId();
21
21
 
22
- useHead({
23
- htmlAttrs: {
24
- lang: "en",
25
- },
26
- });
22
+ const { $t } = useNuxtApp();
27
23
 
28
24
  const { notifications, push, remove } = useNotifications();
29
25
 
@@ -36,7 +32,7 @@ const onError = (err: unknown) => {
36
32
  }
37
33
 
38
34
  push({
39
- title: err instanceof Error ? err.message : "An unexpected error occurred",
35
+ title: err instanceof Error ? err.message : $t("error.unexpected"),
40
36
  variant: "error",
41
37
  });
42
38
  };
@@ -1,11 +1,13 @@
1
- // The vue accordion with an item's `icon` before its label and the
2
- // `expand` icon after it.
1
+ // The vue accordion with an item's `icon` before its label, the `expand`
2
+ // icon after it, and the items' text resolved.
3
3
  import Core from "@zoobzio/vue/components/accordion.vue";
4
4
 
5
5
  import { icon, iconOf } from "./icon";
6
+ import { texts } from "./text";
6
7
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
8
 
8
9
  export default wrap(Core, {
10
+ props: (props) => ({ ...props, items: texts(props.items) }),
9
11
  slots: {
10
12
  triggerPrepend: ({ item }) => iconOf(item.icon),
11
13
  triggerAppend: () => [icon("expand")],
@@ -1,19 +1,14 @@
1
- // The vue autocomplete with the layer's Scroller as the viewport of its
2
- // first panel (the active panel renders with no scroller once a group has
3
- // an option set), the `remove` icon after each chip's label (the chip is the
4
- // button that removes its entry), an option's `icon` before its label, with
5
- // `search` before a literal option that names none (a literal is a value
6
- // typed between its own characters, free text in quotes by default), and
7
- // an arrow after an option that branches: `next` on a field or operator
8
- // option, as selecting it enters a stage, and `expand` on an active trail
9
- // option, as its stage is the one open. A value option commits and a
10
- // literal option is terminal, so neither draws an arrow.
1
+ // The vue autocomplete with the layer's Scroller as its viewport, the
2
+ // `remove` icon on each chip, an option's icon (or `search` for a literal)
3
+ // before its label and an arrow after a field's, and its placeholder
4
+ // resolved.
11
5
  import type { QueryOption } from "@zoobzio/vue/types/components/autocomplete";
12
6
  import type { VNode } from "vue";
13
7
 
14
8
  import Core from "@zoobzio/vue/components/autocomplete.vue";
15
9
 
16
10
  import { icon, iconOf } from "./icon";
11
+ import { textIf } from "./text";
17
12
  import { wrap } from "@zoobzio/vue/utils/wrap";
18
13
  import Scroller from "./scroller";
19
14
 
@@ -26,6 +21,7 @@ const arrow = (option: QueryOption): VNode[] => {
26
21
  };
27
22
 
28
23
  export default wrap(Core, {
24
+ props: (props) => ({ ...props, placeholder: textIf(props.placeholder) }),
29
25
  pt: { viewport: { as: Scroller } },
30
26
  slots: {
31
27
  chipAppend: () => [icon("remove")],
@@ -1,12 +1,18 @@
1
- // The vue breadcrumb with NuxtLink under its `link` part and an item's
2
- // `icon` drawn before its label.
1
+ // The vue breadcrumb with NuxtLink under its `link` part, an item's `icon`
2
+ // before its label, the items' text resolved, and its accessible name in
3
+ // the visitor's locale unless the consumer names it.
3
4
  import Core from "@zoobzio/vue/components/breadcrumb.vue";
4
5
 
5
6
  import NuxtLink from "#app/components/nuxt-link";
6
7
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
8
  import { iconOf } from "./icon";
9
+ import { text, texts } from "./text";
8
10
 
9
11
  export default wrap(Core, {
12
+ props: (props) =>
13
+ Object.assign({ "aria-label": text("breadcrumb.label") }, props, {
14
+ items: texts(props.items),
15
+ }),
10
16
  pt: { link: () => ({ as: NuxtLink }) },
11
17
  slots: { itemPrepend: ({ item }) => iconOf(item.icon) },
12
18
  });
@@ -1,41 +1,65 @@
1
1
  // The vue browser with the layer's parts behind its own: the layer's
2
- // Breadcrumb for the trail, the layer's Menu for file and folder actions
3
- // (so an action's `icon` draws), the layer's Checkbox for the file
4
- // checkboxes, and NuxtLink under the `link` part of its files. Its Fab
5
- // slots draw the `refresh` and `actions` icons; a folder draws `folder`
6
- // before its name; a bulk action draws its own `icon`.
7
- import type { BrowserFilesPassthrough } from "@zoobzio/vue/types/components/browser-files";
2
+ // Breadcrumb as its trail, NuxtLink under the files' `link`, the layer's
3
+ // Menu for file and folder actions (so an action's `icon` draws), the
4
+ // layer's Checkbox for the row checkboxes. Its Fab slots draw the `refresh`
5
+ // and `actions` icons, a folder draws `folder` before its name, a bulk
6
+ // action its own `icon`. Its own text — the refresh and actions labels, the
7
+ // empty states, the clear button — reads in the visitor's locale, and a
8
+ // date, number, currency, file size or boolean cell formats through the
9
+ // app's prosary service.
10
+ import type {
11
+ BrowserFileCellContext,
12
+ BrowserFilesPassthrough,
13
+ } from "@zoobzio/vue/types/components/browser-files";
8
14
  import type { BrowserFoldersPassthrough } from "@zoobzio/vue/types/components/browser-folders";
9
15
 
10
16
  import Core from "@zoobzio/vue/components/browser.vue";
11
17
 
12
18
  import NuxtLink from "#app/components/nuxt-link";
19
+ import { h } from "vue";
13
20
  import { layer } from "@zoobzio/vue/utils/passthrough";
14
21
  import { wrap } from "@zoobzio/vue/utils/wrap";
15
22
  import Breadcrumb from "./breadcrumb";
16
23
  import Checkbox from "./checkbox";
17
24
  import Menu from "./menu";
18
25
  import { icon, iconOf, iconPart } from "./icon";
26
+ import { cellSlots } from "./cell";
27
+ import { text, textSlot } from "./text";
19
28
 
20
29
  export default wrap(Core, {
21
30
  pt: (pt) => ({
22
31
  ...pt,
23
32
  breadcrumb: { as: Breadcrumb, ...pt?.breadcrumb },
33
+ refresh: { label: text("browser.refresh"), ...pt?.refresh },
24
34
  files: layer<BrowserFilesPassthrough<unknown>>(pt?.files, {
25
35
  link: () => ({ as: NuxtLink }),
26
36
  rowCheckbox: { as: Checkbox },
37
+ actionsTrigger: { label: text("browser.actions") },
27
38
  actionsMenu: { as: Menu },
28
39
  }),
29
40
  folders: layer<BrowserFoldersPassthrough>(pt?.folders, {
41
+ actionsTrigger: { label: text("browser.actions") },
30
42
  actionsMenu: { as: Menu },
31
43
  }),
32
44
  }),
33
45
  slots: {
46
+ ...cellSlots<BrowserFileCellContext<unknown>>(
47
+ ({ browser }) => browser.currency,
48
+ ),
34
49
  refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
35
50
  actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
36
51
  folderActions: ({ settings }) =>
37
52
  iconPart(settings.actionsTrigger, "actions"),
38
53
  folderPrepend: () => [icon("folder")],
39
54
  bulkActionPrepend: ({ action }) => iconOf(action.icon),
55
+ bulkClear: () => textSlot("browser.clear"),
56
+ empty: () => [
57
+ h(
58
+ "div",
59
+ { class: "f-group f-data-browser-empty" },
60
+ text("browser.empty"),
61
+ ),
62
+ ],
63
+ noFiles: () => textSlot("browser.noFiles"),
40
64
  },
41
65
  });
@@ -0,0 +1,101 @@
1
+ // The cell glue of the table and browser wrappers: the slot defaults that
2
+ // format a cell's value through the app's prosary service, by the column's
3
+ // type, as `text.ts` resolves its text. Each is a `cell:<type>` slot, so a
4
+ // consumer's `cell:<key>` slot still wins for one column, and a type the
5
+ // layer does not format falls to the vue component's own cell.
6
+ import type { VNode } from "vue";
7
+
8
+ import { useNuxtApp } from "#app";
9
+ import { h } from "vue";
10
+ import { textSlot } from "./text";
11
+
12
+ /** The units a file size climbs through, 1024 at a time. */
13
+ const UNITS = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"] as const;
14
+
15
+ /** A cell's value as the slot scope hands it, with the service's currency. */
16
+ type Cell = { value: unknown; currency: string };
17
+
18
+ /** A formatted value as a cell's content; an absent value as none. */
19
+ const node = (text: string): VNode[] => [h("span", { class: "f-span" }, text)];
20
+
21
+ /** Whether a value is a calendar day, `YYYY-MM-DD`, which formats in UTC. */
22
+ const isCalendarDay = (value: unknown): boolean =>
23
+ typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value);
24
+
25
+ const date = ({ value }: Cell): VNode[] => {
26
+ if (value == null) return node("");
27
+ const { $prosary } = useNuxtApp();
28
+ const at = new Date(String(value));
29
+ return node(
30
+ isCalendarDay(value)
31
+ ? $prosary.date(at, { dateStyle: "medium", timeZone: "UTC" })
32
+ : $prosary.date(at),
33
+ );
34
+ };
35
+
36
+ const datetime = ({ value }: Cell): VNode[] => {
37
+ if (value == null) return node("");
38
+ const { $prosary } = useNuxtApp();
39
+ const at = new Date(String(value));
40
+ return node(`${$prosary.date(at)} ${$prosary.time(at)}`);
41
+ };
42
+
43
+ const number = ({ value }: Cell): VNode[] => {
44
+ if (value == null) return node("");
45
+ return node(useNuxtApp().$prosary.number(Number(value)));
46
+ };
47
+
48
+ const currency = ({ value, currency }: Cell): VNode[] => {
49
+ if (value == null) return node("");
50
+ return node(
51
+ useNuxtApp().$prosary.number(Number(value), {
52
+ style: "currency",
53
+ currency,
54
+ }),
55
+ );
56
+ };
57
+
58
+ const filesize = ({ value }: Cell): VNode[] => {
59
+ if (value == null) return node("");
60
+ let size = Number(value);
61
+ let unit = 0;
62
+ while (size >= 1024 && unit < UNITS.length - 1) {
63
+ size /= 1024;
64
+ unit += 1;
65
+ }
66
+ return node(
67
+ useNuxtApp().$prosary.number(size, {
68
+ style: "unit",
69
+ unit: UNITS[unit],
70
+ unitDisplay: "short",
71
+ maximumFractionDigits: 1,
72
+ }),
73
+ );
74
+ };
75
+
76
+ const boolean = ({ value }: Cell): VNode[] => {
77
+ if (value == null) return node("");
78
+ return [
79
+ h("span", { class: "f-span" }, textSlot(value ? "cell.yes" : "cell.no")),
80
+ ];
81
+ };
82
+
83
+ /**
84
+ * The `cell:<type>` slot defaults, over a reader of the service's currency
85
+ * from the slot's scope: `table` for the table body, `browser` for the
86
+ * browser's files.
87
+ */
88
+ export const cellSlots = <S>(currencyOf: (scope: S) => string) => {
89
+ const cell =
90
+ (format: (cell: Cell) => VNode[]) =>
91
+ (scope: S & { value: unknown }): VNode[] =>
92
+ format({ value: scope.value, currency: currencyOf(scope) });
93
+ return {
94
+ "cell:date": cell(date),
95
+ "cell:datetime": cell(datetime),
96
+ "cell:number": cell(number),
97
+ "cell:currency": cell(currency),
98
+ "cell:filesize": cell(filesize),
99
+ "cell:boolean": cell(boolean),
100
+ };
101
+ };
@@ -0,0 +1,28 @@
1
+ // The vue code editor with its status line — the cursor's line and column,
2
+ // one message with its values — in the visitor's locale.
3
+ import Core from "@zoobzio/vue/components/code.vue";
4
+
5
+ import { h } from "vue";
6
+ import { wrap } from "@zoobzio/vue/utils/wrap";
7
+ import { text } from "./text";
8
+
9
+ export default wrap(Core, {
10
+ slots: {
11
+ status: ({ code, settings }) => [
12
+ h("div", { class: "f-group f-data-code-status", ...settings.status }, [
13
+ h(
14
+ "span",
15
+ {
16
+ class: "f-data-code-cursor",
17
+ "data-line": code.cursor.line,
18
+ "data-column": code.cursor.column,
19
+ },
20
+ text("code.cursor", {
21
+ line: code.cursor.line,
22
+ column: code.cursor.column,
23
+ }),
24
+ ),
25
+ ]),
26
+ ],
27
+ },
28
+ });
@@ -1,14 +1,22 @@
1
1
  // The vue command with the `search` icon before its filter, an item's
2
2
  // `icon` before its label, the layer's Checkbox rendering each item's
3
- // checkbox, and the layer's Scroller as its viewport.
3
+ // checkbox, the layer's Scroller as its viewport, and its text — the
4
+ // groups, the options, the placeholder, the empty state — resolved.
4
5
  import Core from "@zoobzio/vue/components/command.vue";
5
6
 
6
7
  import { icon, iconOf } from "./icon";
8
+ import { textOr, textSlot, texts } from "./text";
7
9
  import { wrap } from "@zoobzio/vue/utils/wrap";
8
10
  import Checkbox from "./checkbox";
9
11
  import Scroller from "./scroller";
10
12
 
11
13
  export default wrap(Core, {
14
+ props: (props) => ({
15
+ ...props,
16
+ groups: texts(props.groups),
17
+ modelValue: texts(props.modelValue),
18
+ placeholder: textOr(props.placeholder, "command.placeholder"),
19
+ }),
12
20
  pt: {
13
21
  viewport: { as: Scroller },
14
22
  itemCheckbox: () => ({ as: Checkbox }),
@@ -16,5 +24,6 @@ export default wrap(Core, {
16
24
  slots: {
17
25
  inputPrepend: () => [icon("search")],
18
26
  itemPrepend: ({ item }) => iconOf(item.icon),
27
+ empty: () => textSlot("command.empty"),
19
28
  },
20
29
  });
@@ -1,22 +1,55 @@
1
- // The vue date filters with the `calendar` icon as the content of its
2
- // trigger, the layer's Command behind its field and operator steps, and
3
- // the layer's Calendar and RangeCalendar behind its date steps.
1
+ // The vue date filters with the layer's Command behind its field and
2
+ // operator steps, the layer's Calendar and RangeCalendar behind its value
3
+ // step, the `calendar` icon as its trigger's content, and its text — the
4
+ // trigger, the fields' labels, the operators, the placeholders, the apply
5
+ // button — in the visitor's locale.
4
6
  import Core from "@zoobzio/vue/components/date-filters.vue";
5
7
 
8
+ import { h } from "vue";
6
9
  import { iconPart } from "./icon";
10
+ import { text, texts } from "./text";
7
11
  import { wrap } from "@zoobzio/vue/utils/wrap";
8
12
  import Calendar from "./calendar";
9
13
  import Command from "./command";
10
14
  import RangeCalendar from "./range-calendar";
11
15
 
12
16
  export default wrap(Core, {
13
- pt: {
14
- fieldCommand: { as: Command },
15
- operatorCommand: { as: Command },
16
- calendar: { as: Calendar },
17
- rangeCalendar: { as: RangeCalendar },
18
- },
17
+ props: (props) => ({ ...props, fields: texts(props.fields) }),
18
+ pt: (pt) => ({
19
+ ...pt,
20
+ trigger: { label: text("dateFilters.trigger"), ...pt?.trigger },
21
+ fieldCommand: {
22
+ as: Command,
23
+ placeholder: text("dateFilters.searchFields"),
24
+ ...pt?.fieldCommand,
25
+ },
26
+ operatorCommand: {
27
+ as: Command,
28
+ placeholder: text("dateFilters.searchOperators"),
29
+ groups: [
30
+ {
31
+ key: "operators",
32
+ label: text("dateFilters.operators"),
33
+ options: [
34
+ { value: "after", label: text("dateFilters.after") },
35
+ { value: "before", label: text("dateFilters.before") },
36
+ { value: "between", label: text("dateFilters.between") },
37
+ ],
38
+ },
39
+ ],
40
+ ...pt?.operatorCommand,
41
+ },
42
+ calendar: { as: Calendar, ...pt?.calendar },
43
+ rangeCalendar: { as: RangeCalendar, ...pt?.rangeCalendar },
44
+ }),
19
45
  slots: {
20
46
  trigger: ({ settings }) => iconPart(settings.trigger, "calendar"),
47
+ applyButton: ({ valid, apply }) => [
48
+ h(
49
+ "button",
50
+ { type: "button", class: "f-button", disabled: !valid, onClick: apply },
51
+ text("dateFilters.apply"),
52
+ ),
53
+ ],
21
54
  },
22
55
  });
@@ -0,0 +1,13 @@
1
+ // The vue dialog with its title and description resolved.
2
+ import Core from "@zoobzio/vue/components/dialog.vue";
3
+
4
+ import { text } from "./text";
5
+ import { wrap } from "@zoobzio/vue/utils/wrap";
6
+
7
+ export default wrap(Core, {
8
+ props: (props) => ({
9
+ ...props,
10
+ title: text(props.title),
11
+ description: text(props.description),
12
+ }),
13
+ });
@@ -1,12 +1,14 @@
1
- // The vue directory with NuxtLink under its `link` part and an item's
2
- // `icon` drawn before its label.
1
+ // The vue directory with NuxtLink under its `link` part, an item's `icon`
2
+ // before its label, and the groups' text resolved.
3
3
  import Core from "@zoobzio/vue/components/directory.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, groups: texts(props.groups) }),
10
12
  pt: { link: () => ({ as: NuxtLink }) },
11
13
  slots: { itemPrepend: ({ item }) => iconOf(item.icon) },
12
14
  });
@@ -1,11 +1,15 @@
1
- // The vue editor with each tool's icon (`toolIcon`, by the tool's
2
- // key) before its label.
1
+ // The vue editor with each tool's icon before its label, and the label in
2
+ // the visitor's locale.
3
3
  import Core from "@zoobzio/vue/components/editor.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
  });
@@ -0,0 +1,9 @@
1
+ // The vue fab with its label resolved.
2
+ import Core from "@zoobzio/vue/components/fab.vue";
3
+
4
+ import { textIf } from "./text";
5
+ import { wrap } from "@zoobzio/vue/utils/wrap";
6
+
7
+ export default wrap(Core, {
8
+ props: (props) => ({ ...props, label: textIf(props.label) }),
9
+ });
@@ -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
  });