@zoobzio/nuxt 0.1.3 → 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.
- package/README.md +17 -10
- package/app/app.d.ts +2 -2
- package/app/components/accordion.ts +3 -3
- package/app/components/breadcrumb.ts +9 -7
- package/app/components/command.ts +13 -4
- package/app/components/date-filters.ts +9 -5
- package/app/components/directory.ts +9 -4
- package/app/components/facets.ts +4 -4
- package/app/components/form-field.ts +15 -3
- package/app/components/hero.ts +6 -7
- package/app/components/listbox.ts +3 -3
- package/app/components/menu.ts +7 -8
- package/app/components/multi-select.ts +19 -6
- package/app/components/radio.ts +5 -3
- package/app/components/segmented-control.ts +7 -4
- package/app/components/select.ts +8 -5
- package/app/components/tabs.ts +6 -4
- package/app/components/text.ts +15 -12
- package/app/components/tree.ts +3 -3
- package/app/factories/browser.ts +9 -11
- package/app/factories/form.ts +11 -9
- package/app/factories/table.ts +14 -12
- package/app/utils/text.ts +7 -4
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -205,8 +205,8 @@ const groups: MenuGroup[] = [
|
|
|
205
205
|
|
|
206
206
|
The components of `@zoobzio/vue` know nothing of translation: each renders
|
|
207
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
|
|
209
|
-
defaults
|
|
208
|
+
The layer translates over the top, through the same `pt` layers and slot
|
|
209
|
+
defaults its wrappers already lay under the components.
|
|
210
210
|
|
|
211
211
|
Every `label`, `placeholder`, `title`, `description` or `hint` a component
|
|
212
212
|
or a service carries is a `Text` of `@zoobzio/kit`: `string`, until a layer
|
|
@@ -244,14 +244,21 @@ export default defineNuxtConfig({
|
|
|
244
244
|
A message resolves at the layer's boundary, before a component sees it, so
|
|
245
245
|
what reaches `@zoobzio/vue` is always a string:
|
|
246
246
|
|
|
247
|
-
- A wrapper
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
|
255
262
|
search then matches a typed prefix against a column's label as the
|
|
256
263
|
visitor reads it. The layer's `locale` plugin reloads the app when the
|
|
257
264
|
visitor switches locale, so a built service never holds a stale one.
|
package/app/app.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type { AppMessage } from "./types/text";
|
|
|
12
12
|
// app's contract, or a key with its values, in place of a string. The
|
|
13
13
|
// contract extends @zoobzio/prose, so the components' own keys are among
|
|
14
14
|
// them. The layer resolves every message at its boundary — a wrapper's
|
|
15
|
-
// props map, a factory — so the components and the
|
|
16
|
-
// only strings, never see one.
|
|
15
|
+
// slot defaults and props map, a factory — so the components and the
|
|
16
|
+
// services, which know only strings, never see one.
|
|
17
17
|
declare module "@zoobzio/kit" {
|
|
18
18
|
interface TextMap {
|
|
19
19
|
app: AppMessage;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// The vue accordion with an item's `icon` before its label, the `expand`
|
|
2
|
-
// icon after it, and the
|
|
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 {
|
|
6
|
+
import { textSlot } from "./text";
|
|
7
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
8
8
|
|
|
9
9
|
export default wrap(Core, {
|
|
10
|
-
props: (props) => ({ ...props, items: texts(props.items) }),
|
|
11
10
|
slots: {
|
|
12
11
|
triggerPrepend: ({ item }) => iconOf(item.icon),
|
|
12
|
+
triggerLabel: ({ item }) => textSlot(item.label),
|
|
13
13
|
triggerAppend: () => [icon("expand")],
|
|
14
14
|
},
|
|
15
15
|
});
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
// The vue breadcrumb with NuxtLink under its `link` part, an item's `icon`
|
|
2
|
-
// before its label, the
|
|
3
|
-
// the visitor's locale unless the consumer names it.
|
|
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.
|
|
4
4
|
import Core from "@zoobzio/vue/components/breadcrumb.vue";
|
|
5
5
|
|
|
6
6
|
import NuxtLink from "#app/components/nuxt-link";
|
|
7
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
8
8
|
import { iconOf } from "./icon";
|
|
9
|
-
import { text,
|
|
9
|
+
import { text, textIn, textSlot } from "./text";
|
|
10
10
|
|
|
11
11
|
export default wrap(Core, {
|
|
12
12
|
props: (props) =>
|
|
13
|
-
Object.assign({ "aria-label": text("breadcrumb.label") }, props,
|
|
14
|
-
items: texts(props.items),
|
|
15
|
-
}),
|
|
13
|
+
Object.assign({ "aria-label": text("breadcrumb.label") }, props),
|
|
16
14
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
17
|
-
slots: {
|
|
15
|
+
slots: {
|
|
16
|
+
itemPrepend: ({ item }) => iconOf(item.icon),
|
|
17
|
+
itemLabel: ({ item, last }) =>
|
|
18
|
+
last ? textSlot(item.label) : textIn("span", "f-span", item.label),
|
|
19
|
+
},
|
|
18
20
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
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
3
|
// checkbox, the layer's Scroller as its viewport, and its text — the
|
|
4
|
-
// groups, the options, the placeholder, the empty state —
|
|
4
|
+
// groups, the options, the placeholder, the empty state — in the
|
|
5
|
+
// visitor's locale.
|
|
5
6
|
import Core from "@zoobzio/vue/components/command.vue";
|
|
6
7
|
|
|
8
|
+
import { ListboxGroupLabel } from "reka-ui";
|
|
9
|
+
import { h } from "vue";
|
|
7
10
|
import { icon, iconOf } from "./icon";
|
|
8
|
-
import { textOr, textSlot
|
|
11
|
+
import { text, textIn, textOr, textSlot } from "./text";
|
|
9
12
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
10
13
|
import Checkbox from "./checkbox";
|
|
11
14
|
import Scroller from "./scroller";
|
|
@@ -13,8 +16,6 @@ import Scroller from "./scroller";
|
|
|
13
16
|
export default wrap(Core, {
|
|
14
17
|
props: (props) => ({
|
|
15
18
|
...props,
|
|
16
|
-
groups: texts(props.groups),
|
|
17
|
-
modelValue: texts(props.modelValue),
|
|
18
19
|
placeholder: textOr(props.placeholder, "command.placeholder"),
|
|
19
20
|
}),
|
|
20
21
|
pt: {
|
|
@@ -23,7 +24,15 @@ export default wrap(Core, {
|
|
|
23
24
|
},
|
|
24
25
|
slots: {
|
|
25
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
|
+
],
|
|
26
34
|
itemPrepend: ({ item }) => iconOf(item.icon),
|
|
35
|
+
itemLabel: ({ item }) => textIn("span", "f-span", item.label),
|
|
27
36
|
empty: () => textSlot("command.empty"),
|
|
28
37
|
},
|
|
29
38
|
});
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// The vue date filters with the layer's Command behind its field and
|
|
2
2
|
// operator steps, the layer's Calendar and RangeCalendar behind its value
|
|
3
3
|
// step, the `calendar` icon as its trigger's content, and its text — the
|
|
4
|
-
// trigger, the
|
|
5
|
-
//
|
|
4
|
+
// trigger, the steps, the operators, the placeholders, the apply button —
|
|
5
|
+
// in the visitor's locale. The fields' labels resolve in the Command.
|
|
6
6
|
import Core from "@zoobzio/vue/components/date-filters.vue";
|
|
7
7
|
|
|
8
|
-
import { h } from "vue";
|
|
8
|
+
import { createTextVNode, h } from "vue";
|
|
9
9
|
import { iconPart } from "./icon";
|
|
10
|
-
import { text,
|
|
10
|
+
import { text, textSlot } from "./text";
|
|
11
11
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
12
12
|
import Calendar from "./calendar";
|
|
13
13
|
import Command from "./command";
|
|
14
14
|
import RangeCalendar from "./range-calendar";
|
|
15
15
|
|
|
16
16
|
export default wrap(Core, {
|
|
17
|
-
props: (props) => ({ ...props, fields: texts(props.fields) }),
|
|
18
17
|
pt: (pt) => ({
|
|
19
18
|
...pt,
|
|
20
19
|
trigger: { label: text("dateFilters.trigger"), ...pt?.trigger },
|
|
@@ -44,6 +43,11 @@ export default wrap(Core, {
|
|
|
44
43
|
}),
|
|
45
44
|
slots: {
|
|
46
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"),
|
|
47
51
|
applyButton: ({ valid, apply }) => [
|
|
48
52
|
h(
|
|
49
53
|
"button",
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
// The vue directory with NuxtLink under its `link` part, an item's `icon`
|
|
2
|
-
// before its label, and
|
|
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";
|
|
8
|
-
import {
|
|
9
|
+
import { textIn } from "./text";
|
|
9
10
|
|
|
10
11
|
export default wrap(Core, {
|
|
11
|
-
props: (props) => ({ ...props, groups: texts(props.groups) }),
|
|
12
12
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
13
|
-
slots: {
|
|
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
|
+
},
|
|
14
19
|
});
|
package/app/components/facets.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
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
|
-
//
|
|
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";
|
|
7
|
-
import { text, textOr
|
|
8
|
+
import { text, textOr } from "./text";
|
|
8
9
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
9
10
|
import Command from "./command";
|
|
10
11
|
|
|
11
12
|
export default wrap(Core, {
|
|
12
13
|
props: (props) => ({
|
|
13
14
|
...props,
|
|
14
|
-
groups: texts(props.groups),
|
|
15
15
|
placeholder: textOr(props.placeholder, "facets.placeholder"),
|
|
16
16
|
}),
|
|
17
17
|
pt: (pt) => ({
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// The vue form field with the layer's inputs behind its parts, and the
|
|
2
|
-
// field's text
|
|
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.
|
|
3
5
|
import Core from "@zoobzio/vue/components/form-field.vue";
|
|
4
6
|
|
|
5
|
-
import {
|
|
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,7 +15,13 @@ import Select from "./select";
|
|
|
13
15
|
import TagsInput from "./tags-input";
|
|
14
16
|
|
|
15
17
|
export default wrap(Core, {
|
|
16
|
-
props: (props) => ({
|
|
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
|
+
}),
|
|
17
25
|
pt: {
|
|
18
26
|
select: { as: Select },
|
|
19
27
|
multiSelect: { as: MultiSelect },
|
|
@@ -23,4 +31,8 @@ export default wrap(Core, {
|
|
|
23
31
|
fileInput: { as: FileInput },
|
|
24
32
|
richText: { as: RichText },
|
|
25
33
|
},
|
|
34
|
+
slots: {
|
|
35
|
+
labelText: ({ field }) => textSlot(field.label),
|
|
36
|
+
hintText: ({ field }) => (field.hint ? textSlot(field.hint) : []),
|
|
37
|
+
},
|
|
26
38
|
});
|
package/app/components/hero.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// The vue hero with NuxtLink under its `link` part, and its description and
|
|
2
|
-
// action
|
|
2
|
+
// its action's label in the visitor's locale.
|
|
3
3
|
import Core from "@zoobzio/vue/components/hero.vue";
|
|
4
4
|
|
|
5
5
|
import NuxtLink from "#app/components/nuxt-link";
|
|
6
6
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
7
|
-
import { textIf,
|
|
7
|
+
import { textIf, textSlot } from "./text";
|
|
8
8
|
|
|
9
9
|
export default wrap(Core, {
|
|
10
|
-
props: (props) => ({
|
|
11
|
-
...props,
|
|
12
|
-
description: textIf(props.description),
|
|
13
|
-
action: texts(props.action),
|
|
14
|
-
}),
|
|
10
|
+
props: (props) => ({ ...props, description: textIf(props.description) }),
|
|
15
11
|
pt: { link: { as: NuxtLink } },
|
|
12
|
+
slots: {
|
|
13
|
+
actionLabel: ({ action }) => (action ? textSlot(action.label) : []),
|
|
14
|
+
},
|
|
16
15
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// The vue listbox with
|
|
1
|
+
// The vue listbox with each item's label in the visitor's locale.
|
|
2
2
|
import Core from "@zoobzio/vue/components/listbox.vue";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { textSlot } from "./text";
|
|
5
5
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
6
|
|
|
7
7
|
export default wrap(Core, {
|
|
8
|
-
|
|
8
|
+
slots: { itemLabel: ({ item }) => textSlot(item.label) },
|
|
9
9
|
});
|
package/app/components/menu.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
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
|
|
3
|
-
//
|
|
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,
|
|
10
|
+
import { textIf, textIn } from "./text";
|
|
11
11
|
|
|
12
12
|
export default wrap(Core, {
|
|
13
|
-
props: (props) => ({
|
|
14
|
-
...props,
|
|
15
|
-
label: textIf(props.label),
|
|
16
|
-
groups: texts(props.groups),
|
|
17
|
-
}),
|
|
13
|
+
props: (props) => ({ ...props, label: textIf(props.label) }),
|
|
18
14
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
19
15
|
slots: {
|
|
16
|
+
groupLabel: ({ group }) =>
|
|
17
|
+
group.label ? textIn("div", "f-caption", group.label) : [],
|
|
20
18
|
itemPrepend: ({ item }) =>
|
|
21
19
|
item.icon ? [h(Icon, { name: item.icon })] : [],
|
|
20
|
+
itemLabel: ({ item }) => textIn("span", "f-span", item.label),
|
|
22
21
|
},
|
|
23
22
|
});
|
|
@@ -1,20 +1,33 @@
|
|
|
1
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
|
-
//
|
|
2
|
+
// checkbox, the `expand` icon after its trigger, and its text — the items,
|
|
3
|
+
// the selection, the placeholder — in the visitor's locale.
|
|
4
4
|
import Core from "@zoobzio/vue/components/multi-select.vue";
|
|
5
5
|
|
|
6
|
+
import { SELECT_TRUNCATE } from "@zoobzio/vue/constants/selection";
|
|
6
7
|
import { icon } from "./icon";
|
|
7
|
-
import { textOr,
|
|
8
|
+
import { text, textIn, textOr, textSlot } from "./text";
|
|
8
9
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
9
10
|
import Checkbox from "./checkbox";
|
|
10
11
|
|
|
11
12
|
export default wrap(Core, {
|
|
12
13
|
props: (props) => ({
|
|
13
14
|
...props,
|
|
14
|
-
items: texts(props.items),
|
|
15
|
-
modelValue: texts(props.modelValue),
|
|
16
15
|
placeholder: textOr(props.placeholder, "select.multiple"),
|
|
17
16
|
}),
|
|
18
17
|
pt: { itemCheckbox: () => ({ as: Checkbox }) },
|
|
19
|
-
slots: {
|
|
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
|
+
},
|
|
20
33
|
});
|
package/app/components/radio.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// The vue radio with
|
|
1
|
+
// The vue radio with each option's label in the visitor's locale.
|
|
2
2
|
import Core from "@zoobzio/vue/components/radio.vue";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { textIn } from "./text";
|
|
5
5
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
6
6
|
|
|
7
7
|
export default wrap(Core, {
|
|
8
|
-
|
|
8
|
+
slots: {
|
|
9
|
+
optionLabel: ({ option }) => textIn("span", "f-span", option.label),
|
|
10
|
+
},
|
|
9
11
|
});
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// The vue segmented control with NuxtLink under its `link` part, an
|
|
2
|
-
// option's `icon` before its label, and the
|
|
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 {
|
|
8
|
+
import { textIn } from "./text";
|
|
9
9
|
|
|
10
10
|
export default wrap(Core, {
|
|
11
|
-
props: (props) => ({ ...props, options: texts(props.options) }),
|
|
12
11
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
13
|
-
slots: {
|
|
12
|
+
slots: {
|
|
13
|
+
itemPrepend: ({ option }) => iconOf(option.icon),
|
|
14
|
+
itemLabel: ({ option }) =>
|
|
15
|
+
option.label ? textIn("span", "f-span", option.label) : [],
|
|
16
|
+
},
|
|
14
17
|
});
|
package/app/components/select.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
// The vue select with the `expand` icon after its display, and its text —
|
|
2
|
-
// the options, the selection, the placeholder —
|
|
2
|
+
// the options, the selection, the placeholder — in the visitor's locale.
|
|
3
3
|
import Core from "@zoobzio/vue/components/select.vue";
|
|
4
4
|
|
|
5
5
|
import { icon } from "./icon";
|
|
6
|
-
import { textOr,
|
|
6
|
+
import { textIn, textOr, textSlot } from "./text";
|
|
7
7
|
import { wrap } from "@zoobzio/vue/utils/wrap";
|
|
8
8
|
|
|
9
9
|
export default wrap(Core, {
|
|
10
10
|
props: (props) => ({
|
|
11
11
|
...props,
|
|
12
|
-
options: texts(props.options),
|
|
13
|
-
modelValue: texts(props.modelValue),
|
|
14
12
|
placeholder: textOr(props.placeholder, "select.placeholder"),
|
|
15
13
|
}),
|
|
16
|
-
slots: {
|
|
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
|
+
},
|
|
17
20
|
});
|
package/app/components/tabs.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// The vue tabs with NuxtLink under its `link` part, a tab's `icon` before
|
|
2
|
-
// its label, and the
|
|
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 {
|
|
8
|
+
import { textSlot } from "./text";
|
|
9
9
|
|
|
10
10
|
export default wrap(Core, {
|
|
11
|
-
props: (props) => ({ ...props, tabs: texts(props.tabs) }),
|
|
12
11
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
13
|
-
slots: {
|
|
12
|
+
slots: {
|
|
13
|
+
triggerPrepend: ({ option }) => iconOf(option.icon),
|
|
14
|
+
triggerLabel: ({ option }) => textSlot(option.label),
|
|
15
|
+
},
|
|
14
16
|
});
|
package/app/components/text.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// The text glue of the wrappers:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
|
5
7
|
// instance, and where what it reads of the service's locale and messages
|
|
6
8
|
// is tracked. Never call one at module scope.
|
|
7
9
|
import type { Contract } from "#build/prosary/index.mjs";
|
|
@@ -12,7 +14,7 @@ import type { VNode } from "vue";
|
|
|
12
14
|
|
|
13
15
|
import { useNuxtApp } from "#app";
|
|
14
16
|
import { createTextVNode, h } from "vue";
|
|
15
|
-
import { resolveText
|
|
17
|
+
import { resolveText } from "../utils/text";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* One text as the visitor reads it, called as `$t` is: a key and its
|
|
@@ -26,13 +28,6 @@ export const text: Format<Contract> & ((value: Text) => string) = (
|
|
|
26
28
|
): string =>
|
|
27
29
|
resolveText(useNuxtApp().$prosary, args.length ? [value, ...args] : value);
|
|
28
30
|
|
|
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
31
|
/**
|
|
37
32
|
* One text as a slot's content: what a slot default returns where the
|
|
38
33
|
* component's own default is its English.
|
|
@@ -41,6 +36,14 @@ export const textSlot = (value: Text): VNode[] => [
|
|
|
41
36
|
createTextVNode(text(value)),
|
|
42
37
|
];
|
|
43
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
|
+
|
|
44
47
|
/**
|
|
45
48
|
* A text that may be absent: resolved when given, absent otherwise, so the
|
|
46
49
|
* component's own default applies.
|
package/app/components/tree.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// The vue tree with NuxtLink under its `link` part, `expand` as the toggle
|
|
2
|
-
// of a node with children, and
|
|
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 {
|
|
8
|
+
import { textSlot } from "./text";
|
|
9
9
|
|
|
10
10
|
export default wrap(Core, {
|
|
11
|
-
props: (props) => ({ ...props, items: texts(props.items) }),
|
|
12
11
|
pt: { link: () => ({ as: NuxtLink }) },
|
|
13
12
|
slots: {
|
|
14
13
|
itemToggle: ({ item }) => (item.hasChildren ? [icon("expand")] : []),
|
|
14
|
+
itemText: ({ item }) => textSlot(item.value.label),
|
|
15
15
|
},
|
|
16
16
|
});
|
package/app/factories/browser.ts
CHANGED
|
@@ -13,10 +13,13 @@ import { resolveTexts } from "../utils/text";
|
|
|
13
13
|
* the wiring (the fetch and the handlers), and `id` keys everything that
|
|
14
14
|
* follows. Each call of the composable, in setup, builds a service over
|
|
15
15
|
* the id's shared store and relays its domain events onto the app logger and the Nuxt hook
|
|
16
|
-
* bus as `browser:updated` and `browser:navigated`.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* bus as `browser:updated` and `browser:navigated`. Every text of the
|
|
17
|
+
* config — the columns' and the actions' labels, the root crumb's —
|
|
18
|
+
* resolves through the app's prosary service as the service is built. A
|
|
19
|
+
* config that names no `rootLabel` takes the contract's `browser.root`,
|
|
20
|
+
* so the root crumb reads in the visitor's locale. The machine itself is
|
|
21
|
+
* `@zoobzio/browser`; the Vue browser renders it through its `service`
|
|
22
|
+
* prop.
|
|
20
23
|
*/
|
|
21
24
|
export const createBrowser = <T>(
|
|
22
25
|
id: string,
|
|
@@ -29,6 +32,7 @@ export const createBrowser = <T>(
|
|
|
29
32
|
const bulk = split(bulkActions);
|
|
30
33
|
const config: Config<T> = {
|
|
31
34
|
...rest,
|
|
35
|
+
rootLabel: rest.rootLabel ?? "browser.root",
|
|
32
36
|
actions: files.descriptors,
|
|
33
37
|
folderActions: folders.descriptors,
|
|
34
38
|
bulkActions: bulk.descriptors,
|
|
@@ -42,13 +46,7 @@ export const createBrowser = <T>(
|
|
|
42
46
|
return (): Service<T> => {
|
|
43
47
|
const nuxt = useNuxtApp();
|
|
44
48
|
const log = nuxt.$logger(id);
|
|
45
|
-
const resolved
|
|
46
|
-
...config,
|
|
47
|
-
columns: resolveTexts(nuxt.$prosary, config.columns),
|
|
48
|
-
actions: resolveTexts(nuxt.$prosary, config.actions),
|
|
49
|
-
folderActions: resolveTexts(nuxt.$prosary, config.folderActions),
|
|
50
|
-
bulkActions: resolveTexts(nuxt.$prosary, config.bulkActions),
|
|
51
|
-
};
|
|
49
|
+
const resolved = resolveTexts(nuxt.$prosary, config);
|
|
52
50
|
const state = accessBrowser<T>(id, initial);
|
|
53
51
|
const service = new BrowserService(id, resolved, state, wiring);
|
|
54
52
|
service.on("updated", (event) => {
|
package/app/factories/form.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormOptions, UseForm } from "../types/form";
|
|
2
|
-
import type { Actions, Service } from "@zoobzio/form";
|
|
2
|
+
import type { Actions, Config, Service } from "@zoobzio/form";
|
|
3
3
|
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
5
|
import { FormService } from "@zoobzio/form";
|
|
@@ -12,23 +12,25 @@ import { resolveTexts } from "../utils/text";
|
|
|
12
12
|
* lifecycle actions and the middleware), and `id` keys everything that
|
|
13
13
|
* follows. Each call of the composable, in setup, builds a service over
|
|
14
14
|
* the id's shared store and relays its domain events onto the app logger and the Nuxt hook
|
|
15
|
-
* bus under the `form:` prefix. The
|
|
16
|
-
* placeholder and option — resolves through the app's prosary
|
|
17
|
-
* the service is built. The
|
|
18
|
-
*
|
|
15
|
+
* bus under the `form:` prefix. The config's text — each field's label,
|
|
16
|
+
* hint, placeholder and option — resolves through the app's prosary
|
|
17
|
+
* service as the service is built. The `defaults` are the payload's
|
|
18
|
+
* values, data rather than text, and stand as given whatever their keys.
|
|
19
|
+
* The machine itself is `@zoobzio/form`; the Vue form renders it through
|
|
20
|
+
* its `service` prop.
|
|
19
21
|
*/
|
|
20
22
|
export const createForm = <T>(
|
|
21
23
|
id: string,
|
|
22
24
|
options: FormOptions<T>,
|
|
23
25
|
): UseForm<T> => {
|
|
24
|
-
const { init, submit, middleware, initial, ...config } = options;
|
|
26
|
+
const { init, submit, middleware, initial, defaults, ...config } = options;
|
|
25
27
|
const wiring: Actions<T> = { init, submit, middleware };
|
|
26
28
|
return (): Service<T> => {
|
|
27
29
|
const nuxt = useNuxtApp();
|
|
28
30
|
const log = nuxt.$logger(id);
|
|
29
|
-
const resolved = {
|
|
30
|
-
...config,
|
|
31
|
-
|
|
31
|
+
const resolved: Config<T> = {
|
|
32
|
+
...resolveTexts(nuxt.$prosary, config),
|
|
33
|
+
...(defaults && { defaults }),
|
|
32
34
|
};
|
|
33
35
|
const state = accessForm(id, resolved, initial);
|
|
34
36
|
const service = new FormService(id, resolved, state, wiring);
|
package/app/factories/table.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { TableOptions, UseTable } from "../types/table";
|
|
|
2
2
|
import type { Actions, Config, Service } from "@zoobzio/table";
|
|
3
3
|
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
|
+
import { QUERY_TEXT_KEY, QUERY_TEXT_LITERAL } from "@zoobzio/query";
|
|
5
6
|
import { TableService } from "@zoobzio/table";
|
|
6
7
|
import { accessTable } from "../stores/table";
|
|
7
8
|
import { split } from "../utils/actions";
|
|
@@ -13,12 +14,15 @@ import { resolveTexts } from "../utils/text";
|
|
|
13
14
|
* wiring (the fetch and the handlers), and `id` keys everything that
|
|
14
15
|
* follows. Each call of the composable, in setup, builds a service over
|
|
15
16
|
* the id's shared store and relays its domain events onto the app logger and the Nuxt hook
|
|
16
|
-
* bus as `table:updated` and `table:filtered`.
|
|
17
|
-
* actions' labels
|
|
18
|
-
* is built, so a label that is a
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* bus as `table:updated` and `table:filtered`. Every text of the config —
|
|
18
|
+
* the columns' and the actions' labels, the literals' — resolves through
|
|
19
|
+
* the app's prosary service as the service is built, so a label that is a
|
|
20
|
+
* key of the app's contract reaches the machine — and the search that
|
|
21
|
+
* matches a typed prefix against it — as the visitor reads it. A config
|
|
22
|
+
* that names no literals takes the query's text literal under the
|
|
23
|
+
* contract's `table.text`, so its option reads in the visitor's locale as
|
|
24
|
+
* the search's placeholder does. The machine itself is `@zoobzio/table`;
|
|
25
|
+
* the Vue table renders it through its `service` prop.
|
|
22
26
|
*/
|
|
23
27
|
export const createTable = <T>(
|
|
24
28
|
id: string,
|
|
@@ -29,6 +33,9 @@ export const createTable = <T>(
|
|
|
29
33
|
const bulk = split(bulkActions);
|
|
30
34
|
const config: Config<T> = {
|
|
31
35
|
...rest,
|
|
36
|
+
literals: rest.literals ?? {
|
|
37
|
+
[QUERY_TEXT_KEY]: { ...QUERY_TEXT_LITERAL, label: "table.text" },
|
|
38
|
+
},
|
|
32
39
|
actions: rows.descriptors,
|
|
33
40
|
bulkActions: bulk.descriptors,
|
|
34
41
|
};
|
|
@@ -40,12 +47,7 @@ export const createTable = <T>(
|
|
|
40
47
|
return (): Service<T> => {
|
|
41
48
|
const nuxt = useNuxtApp();
|
|
42
49
|
const log = nuxt.$logger(id);
|
|
43
|
-
const resolved
|
|
44
|
-
...config,
|
|
45
|
-
columns: resolveTexts(nuxt.$prosary, config.columns),
|
|
46
|
-
actions: resolveTexts(nuxt.$prosary, config.actions),
|
|
47
|
-
bulkActions: resolveTexts(nuxt.$prosary, config.bulkActions),
|
|
48
|
-
};
|
|
50
|
+
const resolved = resolveTexts(nuxt.$prosary, config);
|
|
49
51
|
const state = accessTable(id, resolved, initial);
|
|
50
52
|
const service = new TableService(id, resolved, state, wiring);
|
|
51
53
|
service.on("updated", (event) => {
|
package/app/utils/text.ts
CHANGED
|
@@ -11,6 +11,8 @@ type AppProsary = Prosary<Contract>;
|
|
|
11
11
|
/**
|
|
12
12
|
* The properties that carry text in the data the components and the
|
|
13
13
|
* services take: what {@link resolveTexts} resolves, wherever it finds one.
|
|
14
|
+
* `rootLabel` is the browser's root crumb, the one text a service config
|
|
15
|
+
* carries at its top level.
|
|
14
16
|
*/
|
|
15
17
|
const TEXT_KEYS: ReadonlySet<string> = new Set([
|
|
16
18
|
"label",
|
|
@@ -19,6 +21,7 @@ const TEXT_KEYS: ReadonlySet<string> = new Set([
|
|
|
19
21
|
"placeholder",
|
|
20
22
|
"hint",
|
|
21
23
|
"text",
|
|
24
|
+
"rootLabel",
|
|
22
25
|
]);
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -63,10 +66,10 @@ export const resolveText = (
|
|
|
63
66
|
|
|
64
67
|
/**
|
|
65
68
|
* Resolves every text in a value: the `label`, `description`, `title`,
|
|
66
|
-
* `placeholder`, `hint` and `
|
|
67
|
-
* arrays and plain objects, so the options of a select, the
|
|
68
|
-
* menu, the nodes of a tree or the
|
|
69
|
-
* call. Anything else — a function, a Date, a service — is kept as it is.
|
|
69
|
+
* `placeholder`, `hint`, `text` and `rootLabel` of each plain object, at
|
|
70
|
+
* any depth of arrays and plain objects, so the options of a select, the
|
|
71
|
+
* groups of a menu, the nodes of a tree or the whole config of a table all
|
|
72
|
+
* resolve in one call. Anything else — a function, a Date, a service — is kept as it is.
|
|
70
73
|
* The result is a copy; the value given is never written.
|
|
71
74
|
*
|
|
72
75
|
* @param service - The app's prosary service.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoobzio/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Nuxt layer for the foundation design system: the Nuxt wiring over @zoobzio/vue and the headless services (useState stores, hook-bus factories, app shell).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -38,25 +38,25 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@icon-sheets/nuxt": "0.0.8",
|
|
40
40
|
"@nuxt/kit": "^4.5.0",
|
|
41
|
-
"@prosary/nuxt": "0.0.
|
|
41
|
+
"@prosary/nuxt": "0.0.10",
|
|
42
42
|
"@untheme/nuxt": "^0.6.1",
|
|
43
43
|
"@vueuse/core": "^14.3.0",
|
|
44
44
|
"ltrl-http": "^0.0.20",
|
|
45
45
|
"objectively": "^0.3.0",
|
|
46
|
-
"prosary": "0.0.
|
|
46
|
+
"prosary": "0.0.10",
|
|
47
47
|
"reka-ui": "^2.6.0",
|
|
48
48
|
"untheme": "^0.6.1",
|
|
49
|
-
"@zoobzio/browser": "0.1.
|
|
50
|
-
"@zoobzio/
|
|
51
|
-
"@zoobzio/
|
|
52
|
-
"@zoobzio/
|
|
53
|
-
"@zoobzio/
|
|
54
|
-
"@zoobzio/kit": "0.1.
|
|
55
|
-
"@zoobzio/
|
|
56
|
-
"@zoobzio/
|
|
57
|
-
"@zoobzio/
|
|
58
|
-
"@zoobzio/
|
|
59
|
-
"@zoobzio/
|
|
49
|
+
"@zoobzio/browser": "0.1.4",
|
|
50
|
+
"@zoobzio/form": "0.1.4",
|
|
51
|
+
"@zoobzio/code": "0.1.4",
|
|
52
|
+
"@zoobzio/editor": "0.1.4",
|
|
53
|
+
"@zoobzio/icons": "0.1.4",
|
|
54
|
+
"@zoobzio/kit": "0.1.4",
|
|
55
|
+
"@zoobzio/prose": "0.1.4",
|
|
56
|
+
"@zoobzio/query": "0.1.4",
|
|
57
|
+
"@zoobzio/table": "0.1.4",
|
|
58
|
+
"@zoobzio/theme": "0.1.4",
|
|
59
|
+
"@zoobzio/vue": "0.1.4"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@codemirror/state": "^6.7.6",
|