@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
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,72 @@ 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 and slot
209
+ defaults 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 resolves each text where the component renders it: every
248
+ component exposes a slot around each label it draws (`itemLabel`,
249
+ `groupLabel`, `triggerLabel`, …), and the wrapper's default for that
250
+ slot is the label as the visitor reads it. A scalar text the component
251
+ hands to an attribute — a placeholder, an accessible name — resolves in
252
+ the wrapper's `props` map instead, as no slot can reach it. The
253
+ component's own defaults (a placeholder, an empty state, a button's
254
+ name) come from the prose contract the same way, through its `pt`
255
+ layer and slot defaults. All of it runs on each render, so it follows a
256
+ locale switch.
257
+ - A factory resolves every text of the config it builds a service over —
258
+ the columns, actions, fields and literals — once, when the service is
259
+ built in setup, and lays the contract's messages under the defaults the
260
+ headless packages ship in English: the query's text literal
261
+ (`table.text`) and the browser's root crumb (`browser.root`). The
262
+ search then matches a typed prefix against a column's label as the
263
+ visitor reads it. The layer's `locale` plugin reloads the app when the
264
+ visitor switches locale, so a built service never holds a stale one.
265
+
266
+ `resolveText` and `resolveTexts` are on `#imports`, for code of the app
267
+ that renders text outside a wrapper; `AppMessage` is the message type. A string the contract does not declare — a file name, a value —
268
+ is data, and renders unchanged.
269
+
204
270
  ## Theme
205
271
 
206
272
  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
+ // slot defaults and props map, a factory — so the components and the
16
+ // services, which know 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,13 +1,15 @@
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 each label in the visitor's locale.
3
3
  import Core from "@zoobzio/vue/components/accordion.vue";
4
4
 
5
5
  import { icon, iconOf } from "./icon";
6
+ import { textSlot } from "./text";
6
7
  import { wrap } from "@zoobzio/vue/utils/wrap";
7
8
 
8
9
  export default wrap(Core, {
9
10
  slots: {
10
11
  triggerPrepend: ({ item }) => iconOf(item.icon),
12
+ triggerLabel: ({ item }) => textSlot(item.label),
11
13
  triggerAppend: () => [icon("expand")],
12
14
  },
13
15
  });
@@ -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,20 @@
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, each label in the visitor's locale, and its accessible
3
+ // name in 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, textIn, textSlot } from "./text";
8
10
 
9
11
  export default wrap(Core, {
12
+ props: (props) =>
13
+ Object.assign({ "aria-label": text("breadcrumb.label") }, props),
10
14
  pt: { link: () => ({ as: NuxtLink }) },
11
- slots: { itemPrepend: ({ item }) => iconOf(item.icon) },
15
+ slots: {
16
+ itemPrepend: ({ item }) => iconOf(item.icon),
17
+ itemLabel: ({ item, last }) =>
18
+ last ? textSlot(item.label) : textIn("span", "f-span", item.label),
19
+ },
12
20
  });
@@ -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,20 +1,38 @@
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 — in the
5
+ // visitor's locale.
4
6
  import Core from "@zoobzio/vue/components/command.vue";
5
7
 
8
+ import { ListboxGroupLabel } from "reka-ui";
9
+ import { h } from "vue";
6
10
  import { icon, iconOf } from "./icon";
11
+ import { text, textIn, textOr, textSlot } from "./text";
7
12
  import { wrap } from "@zoobzio/vue/utils/wrap";
8
13
  import Checkbox from "./checkbox";
9
14
  import Scroller from "./scroller";
10
15
 
11
16
  export default wrap(Core, {
17
+ props: (props) => ({
18
+ ...props,
19
+ placeholder: textOr(props.placeholder, "command.placeholder"),
20
+ }),
12
21
  pt: {
13
22
  viewport: { as: Scroller },
14
23
  itemCheckbox: () => ({ as: Checkbox }),
15
24
  },
16
25
  slots: {
17
26
  inputPrepend: () => [icon("search")],
27
+ groupLabel: ({ group, settings }) => [
28
+ h(
29
+ ListboxGroupLabel,
30
+ { class: "f-listbox-group-label", ...settings.groupLabel },
31
+ () => text(group.label),
32
+ ),
33
+ ],
18
34
  itemPrepend: ({ item }) => iconOf(item.icon),
35
+ itemLabel: ({ item }) => textIn("span", "f-span", item.label),
36
+ empty: () => textSlot("command.empty"),
19
37
  },
20
38
  });
@@ -1,22 +1,59 @@
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 steps, the operators, the placeholders, the apply button —
5
+ // in the visitor's locale. The fields' labels resolve in the Command.
4
6
  import Core from "@zoobzio/vue/components/date-filters.vue";
5
7
 
8
+ import { createTextVNode, h } from "vue";
6
9
  import { iconPart } from "./icon";
10
+ import { text, textSlot } 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
+ pt: (pt) => ({
18
+ ...pt,
19
+ trigger: { label: text("dateFilters.trigger"), ...pt?.trigger },
20
+ fieldCommand: {
21
+ as: Command,
22
+ placeholder: text("dateFilters.searchFields"),
23
+ ...pt?.fieldCommand,
24
+ },
25
+ operatorCommand: {
26
+ as: Command,
27
+ placeholder: text("dateFilters.searchOperators"),
28
+ groups: [
29
+ {
30
+ key: "operators",
31
+ label: text("dateFilters.operators"),
32
+ options: [
33
+ { value: "after", label: text("dateFilters.after") },
34
+ { value: "before", label: text("dateFilters.before") },
35
+ { value: "between", label: text("dateFilters.between") },
36
+ ],
37
+ },
38
+ ],
39
+ ...pt?.operatorCommand,
40
+ },
41
+ calendar: { as: Calendar, ...pt?.calendar },
42
+ rangeCalendar: { as: RangeCalendar, ...pt?.rangeCalendar },
43
+ }),
19
44
  slots: {
20
45
  trigger: ({ settings }) => iconPart(settings.trigger, "calendar"),
46
+ fieldLabel: ({ field }) => textSlot(field?.label ?? "dateFilters.field"),
47
+ operatorLabel: ({ operator }) =>
48
+ textSlot(operator ? `dateFilters.${operator}` : "dateFilters.operator"),
49
+ valueLabel: ({ value }) =>
50
+ value ? [createTextVNode(value)] : textSlot("dateFilters.value"),
51
+ applyButton: ({ valid, apply }) => [
52
+ h(
53
+ "button",
54
+ { type: "button", class: "f-button", disabled: !valid, onClick: apply },
55
+ text("dateFilters.apply"),
56
+ ),
57
+ ],
21
58
  },
22
59
  });
@@ -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,19 @@
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 each group's and item's label in the visitor's
3
+ // locale.
3
4
  import Core from "@zoobzio/vue/components/directory.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 { textIn } from "./text";
8
10
 
9
11
  export default wrap(Core, {
10
12
  pt: { link: () => ({ as: NuxtLink }) },
11
- slots: { itemPrepend: ({ item }) => iconOf(item.icon) },
13
+ slots: {
14
+ groupLabel: ({ group }) =>
15
+ group.label ? textIn("div", "f-caption", group.label) : [],
16
+ itemPrepend: ({ item }) => iconOf(item.icon),
17
+ itemLabel: ({ item }) => textIn("span", "f-span", item.label),
18
+ },
12
19
  });
@@ -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
3
+ // placeholder — in the visitor's locale. The groups' and the items' labels
4
+ // resolve in the Command.
4
5
  import Core from "@zoobzio/vue/components/facets.vue";
5
6
 
6
7
  import { iconPart } from "./icon";
8
+ import { text, textOr } from "./text";
7
9
  import { wrap } from "@zoobzio/vue/utils/wrap";
8
10
  import Command from "./command";
9
11
 
10
12
  export default wrap(Core, {
11
- pt: { command: { as: Command } },
13
+ props: (props) => ({
14
+ ...props,
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
  });