Skip to content

Commit 6829f57

Browse files
committed
chore(composables): docblock pass
1 parent 37e1d92 commit 6829f57

File tree

28 files changed

+308
-312
lines changed

28 files changed

+308
-312
lines changed

packages/0/src/composables/createContext/index.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import type { App, InjectionKey } from 'vue'
77
export type ContextKey<Z> = InjectionKey<Z> | string
88

99
/**
10-
* A simple wrapper for tapping into a v0 namespace
10+
* Injects a context provided by an ancestor component.
1111
*
12-
* @param key The provided string or InjectionKey
13-
* @template Z The type values for the context.
14-
* @returns The injected context
15-
* @throws Error if namespace is not found.
12+
* @param key The key of the context to inject.
13+
* @template Z The type of the context.
14+
* @returns The injected context.
15+
* @throws An error if the context is not found.
1616
*
1717
* @see https://vuejs.org/api/composition-api-dependency-injection.html#inject
1818
* @see https://0.vuetifyjs.com/composables/foundation/create-context
@@ -28,12 +28,13 @@ export function useContext<Z> (key: ContextKey<Z>) {
2828
}
2929

3030
/**
31-
* A simple wrapper for providing Vue context.
31+
* Provides a context to all descendant components.
3232
*
33-
* @param key The provided string or InjectionKey
34-
* @param context The context value to provide
35-
* @param app Optional Vue app instance for global provide
36-
* @returns The provided context
33+
* @param key The key of the context to provide.
34+
* @param context The context to provide.
35+
* @param app The Vue app instance to provide the context to.
36+
* @template Z The type of the context.
37+
* @returns The provided context.
3738
*
3839
* @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
3940
* @see https://0.vuetifyjs.com/composables/foundation/create-context
@@ -45,19 +46,20 @@ export function provideContext<Z> (key: ContextKey<Z>, context: Z, app?: App) {
4546
}
4647

4748
/**
48-
* A simple wrapper for Vues provide & inject systems
49+
* Creates a new context for providing and injecting data.
4950
*
50-
* @param key The provided string or InjectionKey
51-
* @template Z The type values for the context.
52-
* @returns A tuple containing provide/inject
51+
* @param _key The key of the context to create.
52+
* @template Z The type of the context.
53+
* @returns A tuple containing the `useContext` and `provideContext` functions.
5354
*
54-
* @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
55+
* @see https://vuejs.org/api/composition-api-dependency-injection.html
5556
* @see https://0.vuetifyjs.com/composables/foundation/create-context
5657
*/
5758
export function createContext<Z> (_key: ContextKey<Z>) {
5859
function _provideContext (context: Z, app?: App) {
5960
return provideContext<Z>(_key, context, app)
6061
}
62+
6163
function _useContext (key = _key) {
6264
return useContext<Z>(key)
6365
}

packages/0/src/composables/createPlugin/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ export interface Plugin {
1212
}
1313

1414
/**
15-
* A universal plugin factory to reduce boilerplate code for Vue plugin creation
15+
* Creates a new Vue plugin.
1616
*
17-
* @param options Configurable object with namespace and provide/setup methods
18-
* @returns A Vue plugin object with install method that runs app w/ context
17+
* @param options The plugin options.
18+
* @returns A new Vue plugin.
1919
*
20-
* @see https://vuejs.org/guide/reusability/plugins
21-
* @see https://vuejs.org/api/application.html#app-runwithcontext
22-
* @see https://0.vuetifyjs.com/factories/create-plugin
20+
* @see https://vuejs.org/guide/reusability/plugins.html
21+
* @see https://0.vuetifyjs.com/composables/foundation/create-plugin
2322
*/
2423
export function createPlugin<Z extends Plugin = Plugin> (options: PluginOptions) {
2524
return {

packages/0/src/composables/createTrinity/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ export type ContextTrinity<Z = unknown> = readonly [
88
]
99

1010
/**
11-
* A tuple containing Vue's provide/inject and a context object
11+
* Creates a new trinity for providing and injecting data.
1212
*
13-
* @param createContext The function that creates the context
14-
* @param provideContext The function that provides context
15-
* @param context The underlying context object singleton
16-
* @template Z The type parameter for the context value
17-
* @template E The vmodel type for the context state.
18-
* @returns [createContext, provideContext, context]
13+
* @param createContext The function that creates the context.
14+
* @param provideContext The function that provides the context.
15+
* @param context The context to provide.
16+
* @template Z The type of the context.
17+
* @returns A new trinity.
1918
*
2019
* @see https://0.vuetifyjs.com/composables/foundation/create-trinity
2120
*/
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// Utilities
22
import { isNullOrUndefined } from '#v0/utilities'
33

4-
/* #__NO_SIDE_EFFECTS__ */
4+
/**
5+
* Converts a value to an array.
6+
*
7+
* @param value The value to convert.
8+
* @template T The type of the value.
9+
* @returns The converted array.
10+
*/
511
export function toArray<T> (value: T | T[]): T[] {
612
return isNullOrUndefined(value) ? [] : (Array.isArray(value) ? value : [value])
713
}

packages/0/src/composables/toReactive/index.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { isRef, reactive, unref } from 'vue'
55
import type { MaybeRef, UnwrapNestedRefs } from 'vue'
66

77
/**
8-
* Converts an object to a reactive reference using Vue's reactivity system.
9-
* This function creates a reactive version of the provided object,
10-
* making its properties automatically track dependencies and trigger re-renders
11-
* when they change.
8+
* Converts a `MaybeRef` to a `UnwrapNestedRefs`.
129
*
13-
* @param objectRef - A reference to an object that should be made reactive.
14-
* @template Z The type of the object that extends object.
15-
* @returns A reactive reference to the object.
10+
* @param objectRef The object to convert.
11+
* @template Z The type of the object.
12+
* @returns The converted object.
1613
*
17-
* @see https://0.vuetifyjs.com/composables/transformers/to-reactive
14+
* @see https://vuejs.org/api/reactivity-utilities.html#toreactive
1815
*/
1916
export function toReactive<Z extends object> (
2017
objectRef: MaybeRef<Z>,

packages/0/src/composables/useBreakpoints/index.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ function createDefaultBreakpoints () {
7171
}
7272

7373
/**
74-
* Creates a reactive breakpoints system for responsive behavior management.
75-
* This function provides access to viewport dimensions, breakpoint detection, and helper flags
76-
* for determining current screen size and implementing responsive logic.
74+
* Creates a new breakpoints instance.
7775
*
78-
* @param options Optional configuration for breakpoint thresholds and mobile breakpoint.
79-
* @returns A breakpoints context object with reactive state and utility methods.
76+
* @param namespace The namespace to use for the breakpoints instance.
77+
* @param options The options for the breakpoints instance.
78+
* @template E The type of the breakpoints context.
79+
* @returns A new breakpoints instance.
8080
*
8181
* @see https://0.vuetifyjs.com/composables/plugins/use-breakpoints
8282
*/
@@ -207,9 +207,9 @@ export function createBreakpoints<
207207
}
208208

209209
/**
210-
* Simple hook to access the breakpoints context.
210+
* Returns the current breakpoints instance.
211211
*
212-
* @returns The breakpoints context containing current breakpoint information.
212+
* @returns The current breakpoints instance.
213213
*
214214
* @see https://0.vuetifyjs.com/composables/plugins/use-breakpoints
215215
*/
@@ -218,12 +218,11 @@ export function useBreakpoints (): BreakpointsContext {
218218
}
219219

220220
/**
221-
* Creates a Vue plugin for managing responsive breakpoints with automatic updates.
222-
* This plugin sets up breakpoint tracking and updates the context when the window
223-
* is resized, providing reactive breakpoint state throughout the application.
221+
* Creates a new breakpoints plugin.
224222
*
225-
* @param options Optional configuration for breakpoint thresholds and mobile breakpoint.
226-
* @returns A Vue plugin object with install method.
223+
* @param options The options for the breakpoints plugin.
224+
* @template E The type of the breakpoints context.
225+
* @returns A new breakpoints plugin.
227226
*
228227
* @see https://0.vuetifyjs.com/composables/plugins/use-breakpoints
229228
*/

packages/0/src/composables/useEventListener/index.ts

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ export type CleanupFunction = () => void
1111
export type EventHandler<E = Event> = (event: E) => void
1212

1313
/**
14-
* Attaches event listeners to the window object with automatic cleanup.
15-
* This overload provides type-safe event handling for window-specific events
16-
* with proper event map typing and automatic listener removal on scope disposal.
14+
* Attaches an event listener to the window.
1715
*
18-
* @param target Window object to attach listeners to.
19-
* @param event Event name(s) to listen for from WindowEventMap.
20-
* @param listener Event handler function(s) with proper window event typing.
21-
* @param options Optional event listener configuration.
22-
* @returns Function to manually remove all attached listeners.
16+
* @param target The window object.
17+
* @param event The event to listen for.
18+
* @param listener The event listener.
19+
* @param options The event listener options.
20+
* @template E The event type.
21+
* @returns A function to remove the event listener.
2322
*
2423
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
2524
*/
@@ -31,15 +30,14 @@ export function useEventListener<E extends keyof WindowEventMap> (
3130
): CleanupFunction
3231

3332
/**
34-
* Attaches event listeners to the document object with automatic cleanup.
35-
* This overload provides type-safe event handling for document-specific events
36-
* with proper event map typing and automatic listener removal on scope disposal.
33+
* Attaches an event listener to the document.
3734
*
38-
* @param target Document object to attach listeners to.
39-
* @param event Event name(s) to listen for from DocumentEventMap.
40-
* @param listener Event handler function(s) with proper document event typing.
41-
* @param options Optional event listener configuration.
42-
* @returns Function to manually remove all attached listeners.
35+
* @param target The document object.
36+
* @param event The event to listen for.
37+
* @param listener The event listener.
38+
* @param options The event listener options.
39+
* @template E The event type.
40+
* @returns A function to remove the event listener.
4341
*
4442
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
4543
*/
@@ -51,15 +49,14 @@ export function useEventListener<E extends keyof DocumentEventMap> (
5149
): CleanupFunction
5250

5351
/**
54-
* Attaches event listeners to HTML elements with automatic cleanup.
55-
* This overload provides type-safe event handling for HTML element events
56-
* with reactive target support and automatic listener removal on scope disposal.
52+
* Attaches an event listener to an HTML element.
5753
*
58-
* @param target HTML element or reactive reference to element.
59-
* @param event Event name(s) to listen for from HTMLElementEventMap.
60-
* @param listener Event handler function(s) with proper HTML element event typing.
61-
* @param options Optional event listener configuration.
62-
* @returns Function to manually remove all attached listeners.
54+
* @param target The HTML element.
55+
* @param event The event to listen for.
56+
* @param listener The event listener.
57+
* @param options The event listener options.
58+
* @template E The event type.
59+
* @returns A function to remove the event listener.
6360
*
6461
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
6562
*/
@@ -71,15 +68,14 @@ export function useEventListener<E extends keyof HTMLElementEventMap> (
7168
): CleanupFunction
7269

7370
/**
74-
* Attaches event listeners to any EventTarget with automatic cleanup.
75-
* This overload provides flexible event handling for any EventTarget implementation
76-
* with reactive target support and automatic listener removal on scope disposal.
71+
* Attaches an event listener to an event target.
7772
*
78-
* @param target EventTarget or reactive reference to target.
79-
* @param event Event name(s) to listen for as string identifiers.
80-
* @param listener Event handler function(s) with customizable event typing.
81-
* @param options Optional event listener configuration.
82-
* @returns Function to manually remove all attached listeners.
73+
* @param target The event target.
74+
* @param event The event to listen for.
75+
* @param listener The event listener.
76+
* @param options The event listener options.
77+
* @template EventType The event type.
78+
* @returns A function to remove the event listener.
8379
*
8480
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
8581
*/
@@ -91,13 +87,13 @@ export function useEventListener<EventType = Event> (
9187
): CleanupFunction
9288

9389
/**
94-
* Attaches event listeners to a target with automatic cleanup.
90+
* Attaches an event listener to a target.
9591
*
96-
* @param target EventTarget or reactive reference to target.
97-
* @param event Event name(s) to listen for as string identifiers.
98-
* @param listener Event handler function(s) with customizable event typing.
99-
* @param options Optional event listener configuration.
100-
* @returns Function to manually remove all attached listeners.
92+
* @param target The target to attach the event listener to.
93+
* @param event The event to listen for.
94+
* @param listener The event listener.
95+
* @param options The event listener options.
96+
* @returns A function to remove the event listener.
10197
*
10298
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
10399
*/
@@ -155,14 +151,13 @@ export function useEventListener (
155151
}
156152

157153
/**
158-
* Convenience function for attaching event listeners to the window object.
159-
* This function provides a simplified API by pre-binding the window target,
160-
* making it easier to handle window-specific events with automatic cleanup.
154+
* Attaches an event listener to the window.
161155
*
162-
* @param event Event name(s) to listen for from WindowEventMap.
163-
* @param listener Event handler function(s) with proper window event typing.
164-
* @param options Optional event listener configuration.
165-
* @returns Function to manually remove all attached listeners.
156+
* @param event The event to listen for.
157+
* @param listener The event listener.
158+
* @param options The event listener options.
159+
* @template E The event type.
160+
* @returns A function to remove the event listener.
166161
*
167162
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
168163
*/
@@ -175,14 +170,13 @@ export function useWindowEventListener<E extends keyof WindowEventMap> (
175170
}
176171

177172
/**
178-
* Convenience function for attaching event listeners to the document object.
179-
* This function provides a simplified API by pre-binding the document target,
180-
* making it easier to handle document-specific events with automatic cleanup.
173+
* Attaches an event listener to the document.
181174
*
182-
* @param event Event name(s) to listen for from DocumentEventMap.
183-
* @param listener Event handler function(s) with proper document event typing.
184-
* @param options Optional event listener configuration.
185-
* @returns Function to manually remove all attached listeners.
175+
* @param event The event to listen for.
176+
* @param listener The event listener.
177+
* @param options The event listener options.
178+
* @template E The event type.
179+
* @returns A function to remove the event listener.
186180
*
187181
* @see https://0.vuetifyjs.com/composables/system/use-event-listener
188182
*/

packages/0/src/composables/useFeatures/index.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export interface FeaturePluginOptions {
3333
}
3434

3535
/**
36-
* Creates a feature management context with support for variations and group selection.
36+
* Creates a new features instance.
3737
*
38-
* @param namespace The namespace for the feature context
39-
* @param options Configure initial features to register
40-
* @template Z The type of feature ticket
41-
* @template E The type of feature context
42-
* @returns A context trinity for the features context
38+
* @param namespace The namespace to use for the features instance.
39+
* @param options The options for the features instance.
40+
* @template Z The type of the feature ticket.
41+
* @template E The type of the feature context.
42+
* @returns A new features instance.
4343
*
4444
* @see https://0.vuetifyjs.com/composables/plugins/create-features
4545
*/
@@ -102,9 +102,10 @@ export function createFeatures<
102102
}
103103

104104
/**
105-
* Simple hook to access the theme context.
105+
* Returns the current features instance.
106106
*
107-
* @returns The features context containing current theme state and utilities.
107+
* @template Z The type of the feature ticket.
108+
* @returns The current features instance.
108109
*
109110
* @see https://0.vuetifyjs.com/composables/plugins/create-features
110111
*/
@@ -113,12 +114,12 @@ export function useFeatures<Z extends FeatureTicket = FeatureTicket> (): Feature
113114
}
114115

115116
/**
116-
* Creates a Vue plugin for feature management with variation support.
117+
* Creates a new features plugin.
117118
*
118-
* @param options Configuration for initial features to register.
119-
* @template Z The type of feature ticket.
120-
* @template E The type of feature context.
121-
* @returns A Vue plugin object with install method.
119+
* @param options The options for the features plugin.
120+
* @template Z The type of the feature ticket.
121+
* @template E The type of the feature context.
122+
* @returns A new features plugin.
122123
*
123124
* @see https://0.vuetifyjs.com/composables/plugins/create-features
124125
*/

0 commit comments

Comments
 (0)