@zoobzio/nuxt 0.1.5 → 0.1.7
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/app/app.vue +1 -1
- package/app/components/browser.ts +2 -4
- package/app/components/cell.ts +23 -13
- package/app/components/table.ts +3 -2
- package/package.json +12 -12
package/app/app.vue
CHANGED
|
@@ -41,7 +41,7 @@ const onError = (err: unknown) => {
|
|
|
41
41
|
<template>
|
|
42
42
|
<ConfigProvider :use-id="useIdFunction">
|
|
43
43
|
<TooltipProvider>
|
|
44
|
-
<NuxtLoadingIndicator color="var(--loading-indicator)" :
|
|
44
|
+
<NuxtLoadingIndicator color="var(--loading-indicator)" :throttle="0" />
|
|
45
45
|
<NuxtErrorBoundary @error="onError">
|
|
46
46
|
<NuxtLayout>
|
|
47
47
|
<NuxtPage />
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// action its own `icon`. Its own text — the refresh and actions labels, the
|
|
7
7
|
// empty states, the clear button — reads in the visitor's locale, and a
|
|
8
8
|
// date, number, currency, file size or boolean cell formats through the
|
|
9
|
-
// app's prosary service.
|
|
9
|
+
// app's prosary service, a date or a datetime in the browser's time zone.
|
|
10
10
|
import type {
|
|
11
11
|
BrowserFileCellContext,
|
|
12
12
|
BrowserFilesPassthrough,
|
|
@@ -43,9 +43,7 @@ export default wrap(Core, {
|
|
|
43
43
|
}),
|
|
44
44
|
}),
|
|
45
45
|
slots: {
|
|
46
|
-
...cellSlots<BrowserFileCellContext<unknown>>(
|
|
47
|
-
({ browser }) => browser.currency,
|
|
48
|
-
),
|
|
46
|
+
...cellSlots<BrowserFileCellContext<unknown>>(({ browser }) => browser),
|
|
49
47
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
50
48
|
actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
|
|
51
49
|
folderActions: ({ settings }) =>
|
package/app/components/cell.ts
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// format a cell's value through the app's prosary service, by the column's
|
|
3
3
|
// type, as `text.ts` resolves its text. Each is a `cell:<type>` slot, so a
|
|
4
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.
|
|
5
|
+
// layer does not format falls to the vue component's own cell. A date or a
|
|
6
|
+
// datetime formats in the service's time zone, as the vue component's own
|
|
7
|
+
// cell does, never the runtime's: a server and a browser render the same
|
|
8
|
+
// text.
|
|
6
9
|
import type { VNode } from "vue";
|
|
7
10
|
|
|
8
11
|
import { useNuxtApp } from "#app";
|
|
@@ -12,8 +15,11 @@ import { textSlot } from "./text";
|
|
|
12
15
|
/** The units a file size climbs through, 1024 at a time. */
|
|
13
16
|
const UNITS = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"] as const;
|
|
14
17
|
|
|
15
|
-
/**
|
|
16
|
-
type
|
|
18
|
+
/** What a cell reads of its service: the currency and the time zone. */
|
|
19
|
+
type Formats = { currency: string; timeZone: string };
|
|
20
|
+
|
|
21
|
+
/** A cell's value as the slot scope hands it, with the service's formats. */
|
|
22
|
+
type Cell = { value: unknown } & Formats;
|
|
17
23
|
|
|
18
24
|
/** A formatted value as a cell's content; an absent value as none. */
|
|
19
25
|
const node = (text: string): VNode[] => [h("span", { class: "f-span" }, text)];
|
|
@@ -22,22 +28,24 @@ const node = (text: string): VNode[] => [h("span", { class: "f-span" }, text)];
|
|
|
22
28
|
const isCalendarDay = (value: unknown): boolean =>
|
|
23
29
|
typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
24
30
|
|
|
25
|
-
const date = ({ value }: Cell): VNode[] => {
|
|
31
|
+
const date = ({ value, timeZone }: Cell): VNode[] => {
|
|
26
32
|
if (value == null) return node("");
|
|
27
33
|
const { $prosary } = useNuxtApp();
|
|
28
34
|
const at = new Date(String(value));
|
|
29
35
|
return node(
|
|
30
36
|
isCalendarDay(value)
|
|
31
37
|
? $prosary.date(at, { dateStyle: "medium", timeZone: "UTC" })
|
|
32
|
-
: $prosary.date(at),
|
|
38
|
+
: $prosary.date(at, { timeZone }),
|
|
33
39
|
);
|
|
34
40
|
};
|
|
35
41
|
|
|
36
|
-
const datetime = ({ value }: Cell): VNode[] => {
|
|
42
|
+
const datetime = ({ value, timeZone }: Cell): VNode[] => {
|
|
37
43
|
if (value == null) return node("");
|
|
38
44
|
const { $prosary } = useNuxtApp();
|
|
39
45
|
const at = new Date(String(value));
|
|
40
|
-
return node(
|
|
46
|
+
return node(
|
|
47
|
+
`${$prosary.date(at, { timeZone })} ${$prosary.time(at, { timeZone })}`,
|
|
48
|
+
);
|
|
41
49
|
};
|
|
42
50
|
|
|
43
51
|
const number = ({ value }: Cell): VNode[] => {
|
|
@@ -81,15 +89,17 @@ const boolean = ({ value }: Cell): VNode[] => {
|
|
|
81
89
|
};
|
|
82
90
|
|
|
83
91
|
/**
|
|
84
|
-
* The `cell:<type>` slot defaults, over a reader of the service
|
|
85
|
-
*
|
|
86
|
-
* browser's files.
|
|
92
|
+
* The `cell:<type>` slot defaults, over a reader of the service from the
|
|
93
|
+
* slot's scope, for its currency and its time zone: `table` for the table
|
|
94
|
+
* body, `browser` for the browser's files.
|
|
87
95
|
*/
|
|
88
|
-
export const cellSlots = <S>(
|
|
96
|
+
export const cellSlots = <S>(serviceOf: (scope: S) => Formats) => {
|
|
89
97
|
const cell =
|
|
90
98
|
(format: (cell: Cell) => VNode[]) =>
|
|
91
|
-
(scope: S & { value: unknown }): VNode[] =>
|
|
92
|
-
|
|
99
|
+
(scope: S & { value: unknown }): VNode[] => {
|
|
100
|
+
const { currency, timeZone } = serviceOf(scope);
|
|
101
|
+
return format({ value: scope.value, currency, timeZone });
|
|
102
|
+
};
|
|
93
103
|
return {
|
|
94
104
|
"cell:date": cell(date),
|
|
95
105
|
"cell:datetime": cell(datetime),
|
package/app/components/table.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// draws its own `icon`. Its own text — the toolbar's labels and
|
|
11
11
|
// placeholders, the empty state, the clear button — reads in the
|
|
12
12
|
// visitor's locale, and a date, number, currency, file size or boolean
|
|
13
|
-
// cell formats through the app's prosary service
|
|
13
|
+
// cell formats through the app's prosary service, a date or a datetime in
|
|
14
|
+
// the table's time zone.
|
|
14
15
|
import type {
|
|
15
16
|
TableBodyPassthrough,
|
|
16
17
|
TableCellContext,
|
|
@@ -57,7 +58,7 @@ export default wrap(Core, {
|
|
|
57
58
|
}),
|
|
58
59
|
}),
|
|
59
60
|
slots: {
|
|
60
|
-
...cellSlots<TableCellContext<unknown>>(({ table }) => table
|
|
61
|
+
...cellSlots<TableCellContext<unknown>>(({ table }) => table),
|
|
61
62
|
refresh: ({ settings }) => iconPart(settings.refresh, "refresh"),
|
|
62
63
|
columns: ({ settings }) => iconPart(settings.trigger, "columns"),
|
|
63
64
|
actions: ({ settings }) => iconPart(settings.actionsTrigger, "actions"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoobzio/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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": {
|
|
@@ -46,17 +46,17 @@
|
|
|
46
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/code": "0.1.
|
|
51
|
-
"@zoobzio/editor": "0.1.
|
|
52
|
-
"@zoobzio/form": "0.1.
|
|
53
|
-
"@zoobzio/icons": "0.1.
|
|
54
|
-
"@zoobzio/kit": "0.1.
|
|
55
|
-
"@zoobzio/prose": "0.1.
|
|
56
|
-
"@zoobzio/query": "0.1.
|
|
57
|
-
"@zoobzio/table": "0.1.
|
|
58
|
-
"@zoobzio/theme": "0.1.
|
|
59
|
-
"@zoobzio/vue": "0.1.
|
|
49
|
+
"@zoobzio/browser": "0.1.7",
|
|
50
|
+
"@zoobzio/code": "0.1.7",
|
|
51
|
+
"@zoobzio/editor": "0.1.7",
|
|
52
|
+
"@zoobzio/form": "0.1.7",
|
|
53
|
+
"@zoobzio/icons": "0.1.7",
|
|
54
|
+
"@zoobzio/kit": "0.1.7",
|
|
55
|
+
"@zoobzio/prose": "0.1.7",
|
|
56
|
+
"@zoobzio/query": "0.1.7",
|
|
57
|
+
"@zoobzio/table": "0.1.7",
|
|
58
|
+
"@zoobzio/theme": "0.1.7",
|
|
59
|
+
"@zoobzio/vue": "0.1.7"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@codemirror/state": "^6.7.6",
|