@zoobzio/nuxt 0.0.1 → 0.0.2

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 CHANGED
@@ -19,21 +19,29 @@ or composables, and bare component tags do not resolve. The registries
19
19
  behind Nuxt's two virtual modules stay live, filled only by
20
20
  `modules/imports/`, so a consumer imports from them explicitly:
21
21
 
22
- - `#components` carries the components of `@zoobzio/vue`.
22
+ - `#components` carries the components of `@zoobzio/vue`. The ones that
23
+ hold links come as the layer's own wrappers, which render every link
24
+ through `NuxtLink` (see [Components](#components)).
23
25
  - `#imports` carries the `define*` constructors of `@zoobzio/vue` and the
24
26
  layer's own surface: the composables, factories, stores, and constants
25
- as values, and everything under `types/` as types.
27
+ as values, and everything under `types/` as types. It also carries the
28
+ types of `@zoobzio/vue` a consumer writes against: the component
29
+ contracts (`SelectProps`, `TableSlots`, `MenuItem`, …), the shared item
30
+ types (`Option`, `Link`, …), and the `define*` and `pt` vocabulary
31
+ (`Definition`, `PT`, …).
26
32
 
27
33
  A consumer never depends on `@zoobzio/vue` itself. The package's
28
- composables are not registered; they build the components and are not a
29
- consumer surface. Nor are the layer's `utils/`, which are the factories'
30
- plumbing.
34
+ composables are not registered, nor are the types behind them (`forward`,
35
+ `refs`, `service`, `events`, `slots`, `context`); they build the
36
+ components and are not a consumer surface. Nor are the layer's `utils/`,
37
+ which are the factories' plumbing.
31
38
 
32
39
  ```ts
33
40
  import { Autocomplete, Select, Table } from "#components";
34
41
  import { defineAutocomplete, defineSelect } from "#imports";
35
42
  import { createTable, useHooks, useLogger } from "#imports";
36
43
  import type { TableOptions } from "#imports";
44
+ import type { Option, SelectProps } from "#imports";
37
45
  ```
38
46
 
39
47
  The same files also ship through subpath exports, the same way
@@ -43,6 +51,43 @@ The same files also ship through subpath exports, the same way
43
51
  import { createTable } from "@zoobzio/nuxt/factories/table";
44
52
  ```
45
53
 
54
+ ## Components
55
+
56
+ The components of `@zoobzio/vue` render links through a `link` passthrough
57
+ part whose recipe is a plain anchor. The layer wraps each component that
58
+ holds one (`Breadcrumb`, `Browser`, `Directory`, `Hero`, `Menu`,
59
+ `SegmentedControl`, `Table`, `Tabs`, `Tree`) in `app/components/`, and the
60
+ wrapper lays `NuxtLink` under that part, so navigation goes through the
61
+ router with no setup. `#components` serves the wrapper under the vue
62
+ component's name; the vue component itself is not registered.
63
+
64
+ A wrapper is the vue component's contract: the same props, emits, slots,
65
+ and `ctx`, typed from the same `@zoobzio/vue` types that `#imports`
66
+ carries. A consumer's `pt.link` composes with the layer's, so an override
67
+ keeps `NuxtLink` unless it sets `as` itself. A disabled item has no
68
+ `href`, and `NuxtLink` renders it as an inert anchor.
69
+
70
+ ```vue
71
+ <script setup lang="ts">
72
+ import { Breadcrumb } from "#components";
73
+ import type { BreadcrumbItem } from "#imports";
74
+
75
+ const items: BreadcrumbItem[] = [
76
+ { key: "home", label: "Home", link: { to: "/" } },
77
+ { key: "docs", label: "Docs" },
78
+ ];
79
+ </script>
80
+
81
+ <template>
82
+ <!-- "Home" renders as <NuxtLink href="/">; `pt.link` adds a class -->
83
+ <Breadcrumb :items="items" :pt="{ link: () => ({ class: 'crumb' }) }" />
84
+ </template>
85
+ ```
86
+
87
+ `Table` and `Browser` lay the part under their nested manifests (`pt.body`,
88
+ `pt.files`, and the browser's `pt.breadcrumb.pt`), so a consumer's part at
89
+ the same path composes the same way.
90
+
46
91
  ## Stores and factories
47
92
 
48
93
  The data components of `@zoobzio/vue` (`Table`, `Form`, `Browser`) render a
@@ -226,7 +271,7 @@ app/
226
271
  stores/ — access<Name>(id, …) → the id's shared state container; accessLogs, accessNotifications
227
272
  types/ — per-feature options, initial state, and hook maps; hook, log, notification, error, request
228
273
  utils/ — split (actions → descriptors + handlers), seed (state)
229
- modules/ — local Nuxt modules: imports/ fills #components and #imports (the @zoobzio/vue surface and the layer's own)
274
+ modules/ — local Nuxt modules: imports/ fills #components and #imports (the @zoobzio/vue components, definitions, and types, and the layer's own surface) and references app.d.ts for consumers
230
275
  tests/ — vitest + happy-dom, mirroring app/ path-for-path
231
276
  nuxt.config.ts — layer config (no implicit imports, no component scanning or tag resolution; loads the reset)
232
277
  ```
package/app/app.vue CHANGED
@@ -11,7 +11,8 @@ import {
11
11
  } from "#components";
12
12
 
13
13
  import { ConfigProvider, TooltipProvider } from "reka-ui";
14
- import { useHead, useId } from "#imports";
14
+ import { isNuxtError, useHead } from "#app";
15
+ import { useId } from "vue";
15
16
  import { useNotifications } from "./composables/notification";
16
17
  </script>
17
18
 
@@ -27,10 +28,7 @@ useHead({
27
28
  const { notifications, push, remove } = useNotifications();
28
29
 
29
30
  const onError = (err: unknown) => {
30
- const data =
31
- err instanceof Error && "data" in err
32
- ? (err.data as ErrorData | undefined)
33
- : undefined;
31
+ const data = isNuxtError<ErrorData>(err) ? err.data : undefined;
34
32
 
35
33
  if (data?.notification) {
36
34
  push(data.notification);
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import type {
3
+ BreadcrumbContext,
4
+ BreadcrumbEmits,
5
+ BreadcrumbItem,
6
+ BreadcrumbPassthrough,
7
+ BreadcrumbProps,
8
+ BreadcrumbSlots,
9
+ } from "@zoobzio/vue/types/components/breadcrumb";
10
+ import type { Context } from "@zoobzio/vue/types/context";
11
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
12
+ import type { VNodeProps } from "vue";
13
+
14
+ import Core from "@zoobzio/vue/components/breadcrumb.vue";
15
+
16
+ import NuxtLink from "#app/components/nuxt-link";
17
+ import { shallowRef, useAttrs } from "vue";
18
+ import { useContext } from "@zoobzio/vue/composables/context";
19
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
20
+ import { useForward } from "@zoobzio/vue/composables/forward";
21
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
22
+ </script>
23
+
24
+ <script setup lang="ts" generic="T extends BreadcrumbItem">
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = defineProps<BreadcrumbProps<T>>();
28
+
29
+ const emit = defineEmits<BreadcrumbEmits<T>>();
30
+
31
+ const slots = defineSlots<BreadcrumbSlots<T>>();
32
+
33
+ const attrs = useAttrs();
34
+
35
+ const explicit = useExplicit(props);
36
+
37
+ const el = shallowRef<{ ctx: Context<BreadcrumbContext<T>> } | null>(null);
38
+
39
+ const pt = usePassthrough<BreadcrumbPassthrough<T>>(() => ({
40
+ pt: props.pt,
41
+ layer: { link: () => ({ as: NuxtLink }) },
42
+ }));
43
+
44
+ const ctx = useContext(() => el.value?.ctx);
45
+
46
+ const Breadcrumb = useForward<
47
+ Passthrough<BreadcrumbProps<T>, BreadcrumbEmits<T>> & VNodeProps
48
+ >({
49
+ component: Core,
50
+ props: () => ({
51
+ ...attrs,
52
+ ...explicit.value,
53
+ pt: pt.value,
54
+ ref: el,
55
+ onSelect: (item: T) => emit("select", item),
56
+ }),
57
+ slots,
58
+ });
59
+
60
+ defineExpose({ ctx });
61
+ </script>
62
+
63
+ <template>
64
+ <Breadcrumb />
65
+ </template>
@@ -0,0 +1,79 @@
1
+ <script lang="ts">
2
+ import type {
3
+ BrowserContext,
4
+ BrowserCrumbItem,
5
+ BrowserEmits,
6
+ BrowserProps,
7
+ BrowserSlots,
8
+ } from "@zoobzio/vue/types/components/browser";
9
+ import type { BreadcrumbPassthrough } from "@zoobzio/vue/types/components/breadcrumb";
10
+ import type { BrowserFilesPassthrough } from "@zoobzio/vue/types/components/browser-files";
11
+ import type { Context } from "@zoobzio/vue/types/context";
12
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
13
+ import type { VNodeProps } from "vue";
14
+
15
+ import Core from "@zoobzio/vue/components/browser.vue";
16
+
17
+ import NuxtLink from "#app/components/nuxt-link";
18
+ import { shallowRef, useAttrs } from "vue";
19
+ import { useContext } from "@zoobzio/vue/composables/context";
20
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
21
+ import { useForward } from "@zoobzio/vue/composables/forward";
22
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
23
+
24
+ type BrowserUpdated = BrowserEmits<unknown>["updated"][0];
25
+ type BrowserNavigated = BrowserEmits<unknown>["navigated"][0];
26
+ </script>
27
+
28
+ <script setup lang="ts" generic="T">
29
+ defineOptions({ inheritAttrs: false });
30
+
31
+ const props = defineProps<BrowserProps<T>>();
32
+
33
+ const emit = defineEmits<BrowserEmits<T>>();
34
+
35
+ const slots = defineSlots<BrowserSlots<T>>();
36
+
37
+ const attrs = useAttrs();
38
+
39
+ const explicit = useExplicit(props);
40
+
41
+ const el = shallowRef<{ ctx: Context<BrowserContext<T>> } | null>(null);
42
+
43
+ const files = usePassthrough<BrowserFilesPassthrough<T>>(() => ({
44
+ pt: props.pt?.files,
45
+ layer: { link: () => ({ as: NuxtLink }) },
46
+ }));
47
+
48
+ const crumbs = usePassthrough<BreadcrumbPassthrough<BrowserCrumbItem>>(() => ({
49
+ pt: props.pt?.breadcrumb?.pt,
50
+ layer: { link: () => ({ as: NuxtLink }) },
51
+ }));
52
+
53
+ const ctx = useContext(() => el.value?.ctx);
54
+
55
+ const Browser = useForward<
56
+ Passthrough<BrowserProps<T>, BrowserEmits<T>> & VNodeProps
57
+ >({
58
+ component: Core,
59
+ props: () => ({
60
+ ...attrs,
61
+ ...explicit.value,
62
+ pt: {
63
+ ...props.pt,
64
+ files: files.value,
65
+ breadcrumb: { ...props.pt?.breadcrumb, pt: crumbs.value },
66
+ },
67
+ ref: el,
68
+ onUpdated: (event: BrowserUpdated) => emit("updated", event),
69
+ onNavigated: (event: BrowserNavigated) => emit("navigated", event),
70
+ }),
71
+ slots,
72
+ });
73
+
74
+ defineExpose({ ctx });
75
+ </script>
76
+
77
+ <template>
78
+ <Browser />
79
+ </template>
@@ -0,0 +1,65 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DirectoryContext,
4
+ DirectoryEmits,
5
+ DirectoryItem,
6
+ DirectoryPassthrough,
7
+ DirectoryProps,
8
+ DirectorySlots,
9
+ } from "@zoobzio/vue/types/components/directory";
10
+ import type { Context } from "@zoobzio/vue/types/context";
11
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
12
+ import type { VNodeProps } from "vue";
13
+
14
+ import Core from "@zoobzio/vue/components/directory.vue";
15
+
16
+ import NuxtLink from "#app/components/nuxt-link";
17
+ import { shallowRef, useAttrs } from "vue";
18
+ import { useContext } from "@zoobzio/vue/composables/context";
19
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
20
+ import { useForward } from "@zoobzio/vue/composables/forward";
21
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
22
+ </script>
23
+
24
+ <script setup lang="ts" generic="T extends DirectoryItem">
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = defineProps<DirectoryProps<T>>();
28
+
29
+ const emit = defineEmits<DirectoryEmits<T>>();
30
+
31
+ const slots = defineSlots<DirectorySlots<T>>();
32
+
33
+ const attrs = useAttrs();
34
+
35
+ const explicit = useExplicit(props);
36
+
37
+ const el = shallowRef<{ ctx: Context<DirectoryContext<T>> } | null>(null);
38
+
39
+ const pt = usePassthrough<DirectoryPassthrough<T>>(() => ({
40
+ pt: props.pt,
41
+ layer: { link: () => ({ as: NuxtLink }) },
42
+ }));
43
+
44
+ const ctx = useContext(() => el.value?.ctx);
45
+
46
+ const Directory = useForward<
47
+ Passthrough<DirectoryProps<T>, DirectoryEmits<T>> & VNodeProps
48
+ >({
49
+ component: Core,
50
+ props: () => ({
51
+ ...attrs,
52
+ ...explicit.value,
53
+ pt: pt.value,
54
+ ref: el,
55
+ onSelect: (item: T) => emit("select", item),
56
+ }),
57
+ slots,
58
+ });
59
+
60
+ defineExpose({ ctx });
61
+ </script>
62
+
63
+ <template>
64
+ <Directory />
65
+ </template>
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import type {
3
+ HeroContext,
4
+ HeroEmits,
5
+ HeroPassthrough,
6
+ HeroProps,
7
+ HeroSlots,
8
+ } from "@zoobzio/vue/types/components/hero";
9
+ import type { Context } from "@zoobzio/vue/types/context";
10
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
11
+ import type { VNodeProps } from "vue";
12
+
13
+ import Core from "@zoobzio/vue/components/hero.vue";
14
+
15
+ import NuxtLink from "#app/components/nuxt-link";
16
+ import { shallowRef, useAttrs } from "vue";
17
+ import { useContext } from "@zoobzio/vue/composables/context";
18
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
19
+ import { useForward } from "@zoobzio/vue/composables/forward";
20
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
21
+ </script>
22
+
23
+ <script setup lang="ts">
24
+ defineOptions({ inheritAttrs: false });
25
+
26
+ const props = defineProps<HeroProps>();
27
+
28
+ const slots = defineSlots<HeroSlots>();
29
+
30
+ const attrs = useAttrs();
31
+
32
+ const explicit = useExplicit(props);
33
+
34
+ const el = shallowRef<{ ctx: Context<HeroContext> } | null>(null);
35
+
36
+ const pt = usePassthrough<HeroPassthrough>(() => ({
37
+ pt: props.pt,
38
+ layer: { link: { as: NuxtLink } },
39
+ }));
40
+
41
+ const ctx = useContext(() => el.value?.ctx);
42
+
43
+ const Hero = useForward<Passthrough<HeroProps, HeroEmits> & VNodeProps>({
44
+ component: Core,
45
+ props: () => ({
46
+ ...attrs,
47
+ ...explicit.value,
48
+ pt: pt.value,
49
+ ref: el,
50
+ }),
51
+ slots,
52
+ });
53
+
54
+ defineExpose({ ctx });
55
+ </script>
56
+
57
+ <template>
58
+ <Hero />
59
+ </template>
@@ -0,0 +1,64 @@
1
+ <script lang="ts">
2
+ import type {
3
+ MenuContext,
4
+ MenuEmits,
5
+ MenuItem,
6
+ MenuPassthrough,
7
+ MenuProps,
8
+ MenuSlots,
9
+ } from "@zoobzio/vue/types/components/menu";
10
+ import type { Context } from "@zoobzio/vue/types/context";
11
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
12
+ import type { VNodeProps } from "vue";
13
+
14
+ import Core from "@zoobzio/vue/components/menu.vue";
15
+
16
+ import NuxtLink from "#app/components/nuxt-link";
17
+ import { shallowRef, useAttrs } from "vue";
18
+ import { useContext } from "@zoobzio/vue/composables/context";
19
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
20
+ import { useForward } from "@zoobzio/vue/composables/forward";
21
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
22
+ </script>
23
+
24
+ <script setup lang="ts" generic="T extends MenuItem">
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = defineProps<MenuProps<T>>();
28
+
29
+ const emit = defineEmits<MenuEmits<T>>();
30
+
31
+ const slots = defineSlots<MenuSlots<T>>();
32
+
33
+ const attrs = useAttrs();
34
+
35
+ const explicit = useExplicit(props);
36
+
37
+ const el = shallowRef<{ ctx: Context<MenuContext<T>> } | null>(null);
38
+
39
+ const pt = usePassthrough<MenuPassthrough<T>>(() => ({
40
+ pt: props.pt,
41
+ layer: { link: () => ({ as: NuxtLink }) },
42
+ }));
43
+
44
+ const ctx = useContext(() => el.value?.ctx);
45
+
46
+ const Menu = useForward<Passthrough<MenuProps<T>, MenuEmits<T>> & VNodeProps>({
47
+ component: Core,
48
+ props: () => ({
49
+ ...attrs,
50
+ ...explicit.value,
51
+ pt: pt.value,
52
+ ref: el,
53
+ onSelect: (item: T) => emit("select", item),
54
+ "onUpdate:open": (value: boolean) => emit("update:open", value),
55
+ }),
56
+ slots,
57
+ });
58
+
59
+ defineExpose({ ctx });
60
+ </script>
61
+
62
+ <template>
63
+ <Menu />
64
+ </template>
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import type {
3
+ SegmentedControlContext,
4
+ SegmentedControlEmits,
5
+ SegmentedControlOption,
6
+ SegmentedControlPassthrough,
7
+ SegmentedControlProps,
8
+ SegmentedControlSlots,
9
+ } from "@zoobzio/vue/types/components/segmented-control";
10
+ import type { Context } from "@zoobzio/vue/types/context";
11
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
12
+ import type { VNodeProps } from "vue";
13
+
14
+ import Core from "@zoobzio/vue/components/segmented-control.vue";
15
+
16
+ import NuxtLink from "#app/components/nuxt-link";
17
+ import { shallowRef, useAttrs } from "vue";
18
+ import { useContext } from "@zoobzio/vue/composables/context";
19
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
20
+ import { useForward } from "@zoobzio/vue/composables/forward";
21
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
22
+ </script>
23
+
24
+ <script setup lang="ts" generic="T extends SegmentedControlOption">
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = defineProps<SegmentedControlProps<T>>();
28
+
29
+ const emit = defineEmits<SegmentedControlEmits>();
30
+
31
+ const slots = defineSlots<SegmentedControlSlots<T>>();
32
+
33
+ const attrs = useAttrs();
34
+
35
+ const explicit = useExplicit(props);
36
+
37
+ const el = shallowRef<{ ctx: Context<SegmentedControlContext<T>> } | null>(
38
+ null,
39
+ );
40
+
41
+ const pt = usePassthrough<SegmentedControlPassthrough<T>>(() => ({
42
+ pt: props.pt,
43
+ layer: { link: () => ({ as: NuxtLink }) },
44
+ }));
45
+
46
+ const ctx = useContext(() => el.value?.ctx);
47
+
48
+ const SegmentedControl = useForward<
49
+ Passthrough<SegmentedControlProps<T>, SegmentedControlEmits> & VNodeProps
50
+ >({
51
+ component: Core,
52
+ props: () => ({
53
+ ...attrs,
54
+ ...explicit.value,
55
+ pt: pt.value,
56
+ ref: el,
57
+ "onUpdate:modelValue": (value: string) => emit("update:modelValue", value),
58
+ }),
59
+ slots,
60
+ });
61
+
62
+ defineExpose({ ctx });
63
+ </script>
64
+
65
+ <template>
66
+ <SegmentedControl />
67
+ </template>
@@ -0,0 +1,68 @@
1
+ <script lang="ts">
2
+ import type {
3
+ TableContext,
4
+ TableEmits,
5
+ TableProps,
6
+ TableSlots,
7
+ } from "@zoobzio/vue/types/components/table";
8
+ import type { TableBodyPassthrough } from "@zoobzio/vue/types/components/table-body";
9
+ import type { Context } from "@zoobzio/vue/types/context";
10
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
11
+ import type { VNodeProps } from "vue";
12
+
13
+ import Core from "@zoobzio/vue/components/table.vue";
14
+
15
+ import NuxtLink from "#app/components/nuxt-link";
16
+ import { shallowRef, useAttrs } from "vue";
17
+ import { useContext } from "@zoobzio/vue/composables/context";
18
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
19
+ import { useForward } from "@zoobzio/vue/composables/forward";
20
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
21
+
22
+ type TableUpdated = TableEmits<unknown>["updated"][0];
23
+ type TableFiltered = TableEmits<unknown>["filtered"][0];
24
+ </script>
25
+
26
+ <script setup lang="ts" generic="T">
27
+ defineOptions({ inheritAttrs: false });
28
+
29
+ const props = defineProps<TableProps<T>>();
30
+
31
+ const emit = defineEmits<TableEmits<T>>();
32
+
33
+ const slots = defineSlots<TableSlots<T>>();
34
+
35
+ const attrs = useAttrs();
36
+
37
+ const explicit = useExplicit(props);
38
+
39
+ const el = shallowRef<{ ctx: Context<TableContext<T>> } | null>(null);
40
+
41
+ const body = usePassthrough<TableBodyPassthrough<T>>(() => ({
42
+ pt: props.pt?.body,
43
+ layer: { link: () => ({ as: NuxtLink }) },
44
+ }));
45
+
46
+ const ctx = useContext(() => el.value?.ctx);
47
+
48
+ const Table = useForward<
49
+ Passthrough<TableProps<T>, TableEmits<T>> & VNodeProps
50
+ >({
51
+ component: Core,
52
+ props: () => ({
53
+ ...attrs,
54
+ ...explicit.value,
55
+ pt: { ...props.pt, body: body.value },
56
+ ref: el,
57
+ onUpdated: (event: TableUpdated) => emit("updated", event),
58
+ onFiltered: (event: TableFiltered) => emit("filtered", event),
59
+ }),
60
+ slots,
61
+ });
62
+
63
+ defineExpose({ ctx });
64
+ </script>
65
+
66
+ <template>
67
+ <Table />
68
+ </template>
@@ -0,0 +1,63 @@
1
+ <script lang="ts">
2
+ import type {
3
+ TabsContext,
4
+ TabsEmits,
5
+ TabsOption,
6
+ TabsPassthrough,
7
+ TabsProps,
8
+ TabsSlots,
9
+ } from "@zoobzio/vue/types/components/tabs";
10
+ import type { Context } from "@zoobzio/vue/types/context";
11
+ import type { Passthrough } from "@zoobzio/vue/types/passthrough";
12
+ import type { VNodeProps } from "vue";
13
+
14
+ import Core from "@zoobzio/vue/components/tabs.vue";
15
+
16
+ import NuxtLink from "#app/components/nuxt-link";
17
+ import { shallowRef, useAttrs } from "vue";
18
+ import { useContext } from "@zoobzio/vue/composables/context";
19
+ import { useExplicit } from "@zoobzio/vue/composables/explicit";
20
+ import { useForward } from "@zoobzio/vue/composables/forward";
21
+ import { usePassthrough } from "@zoobzio/vue/composables/passthrough";
22
+ </script>
23
+
24
+ <script setup lang="ts" generic="T extends TabsOption">
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ const props = defineProps<TabsProps<T>>();
28
+
29
+ const emit = defineEmits<TabsEmits>();
30
+
31
+ const slots = defineSlots<TabsSlots<T>>();
32
+
33
+ const attrs = useAttrs();
34
+
35
+ const explicit = useExplicit(props);
36
+
37
+ const el = shallowRef<{ ctx: Context<TabsContext<T>> } | null>(null);
38
+
39
+ const pt = usePassthrough<TabsPassthrough<T>>(() => ({
40
+ pt: props.pt,
41
+ layer: { link: () => ({ as: NuxtLink }) },
42
+ }));
43
+
44
+ const ctx = useContext(() => el.value?.ctx);
45
+
46
+ const Tabs = useForward<Passthrough<TabsProps<T>, TabsEmits> & VNodeProps>({
47
+ component: Core,
48
+ props: () => ({
49
+ ...attrs,
50
+ ...explicit.value,
51
+ pt: pt.value,
52
+ ref: el,
53
+ "onUpdate:modelValue": (value: string) => emit("update:modelValue", value),
54
+ }),
55
+ slots,
56
+ });
57
+
58
+ defineExpose({ ctx });
59
+ </script>
60
+
61
+ <template>
62
+ <Tabs />
63
+ </template>