Skip to content

@nhtio/common-vue

Provides the helper interfaces, types, variables and functions needed to create custom components.

Components

ClassDescription
BaseFieldThe BaseField component provides a base input field with support for Vue Composition API hooks, custom event handlers, and both VInput and VField functionality from Vuetify. Features include focus management, model value binding, and flexible slot support.

Composables

FunctionDescription
useBaseHooksComposable that creates passthrough hooks for all BaseField events. Integrates with component props (onX handlers) and hook arrays (callOnX) to handle events.
useBasePropsComposable that extracts and filters BaseField props into typed computed references. Provides both all defined props and a filtered set with undefined values removed.
useBaseSlotsComposable that extracts and provides typed slot renderer functions for all BaseField slots. Returns an object with individual slot renderer functions that safely invoke slots with proper typing. Each renderer function accepts slot parameters and returns the slot's render result or undefined.
useLocalizedModelValueComposable for managing localized/transformed model values with bidirectional synchronization.
usePassthroughHookBuilds an event invoker that respects component-bound handlers and hook arrays before calling a fallback.

Constants

NameDescription
baseEmitsEmit definitions for the BaseField component. Contains all standard emit validators for field component events.
baseFieldBaseRawEmitsBase emit validators for the BaseField component. Defines all standard emit events that can be emitted by field components, including clicks, focus updates, and model value changes.
versionThe current version of the package.
iconClosePre-configured close icon using Material Design Icons. Can be used as the clear icon or any other close icon action.

Factories

NameDescription
makeBasePropsFactory function that creates props for the BaseField component. Returns a function that accepts optional defaults and returns fully typed prop definitions.
emitsFactoryCreates emit functions from emit validators. Simply type-casts validators to emit functions; the actual validation happens elsewhere.
propsAndEmitsFactoryFactory that combines props and emits definitions into a unified system. Automatically adds handler props (onX) for each emit, supporting both camelCase and kebab-case.

Other

NameDescription
BaseHookHandlers-
IconValue-
IconValue-
VFieldSlots-
VInputSlots-
omit-
pick-

Types

NameDescription
EmitValidatorsInterface for emit event validators. Each validator is a function that takes event arguments and returns a boolean indicating validity.
AppendDefaultApplies default values to component prop definitions. For each prop, if a default is provided, it updates the prop's default and type accordingly.
BaseClickAppendInnerHookHandlerHook handler type for the 'click:appendInner' event
BaseClickClearHookHandlerHook handler type for the 'click:clear' event
BaseClickControlHookHandlerHook handler type for the 'click:control' event
BaseClickPrependInnerHookHandlerHook handler type for the 'click:prependInner' event
BaseHookableEventsType for the hookable events of BaseField
BaseHookableRawEventsType for the raw emit validators of BaseField
BaseHooksType for the hooks system for BaseField
BaseMousedownControlHookHandlerHook handler type for the 'mousedown:control' event
BasePropsThe public prop types of the BaseField component
BaseSetupPropsThe complete prop types (including setup) of the BaseField component
BaseSlotsThe slot types of the BaseField component, combining VInput and VField slots
BaseUpdateFocusedHookHandlerHook handler type for the 'update:focused' event
BaseUpdateModelValueHookHandlerHook handler type for the 'update:modelValue' event
CastToEmitValidatorsConverts emit functions back into emit validators. Maps emit functions (args => void) to validator signatures (args => boolean).
ComponentPublicInstanceTypeUtility type that merges a component constructor's instance type with Vue's ComponentPublicInstance. Provides proper typing for component instances that includes both the component's own properties/methods and Vue's public instance API (e.g., $el, $emit, $props, etc.).
EmitFunctionsConverts emit validators into emit functions. Maps validator signatures (args => boolean) to emit functions (args => void).
EmitHandlerPropsType helper that generates emit handler prop types from emit validators. Creates both camelCase and kebab-case variants for each emit.
ExtractPrivatePropTypesFromFactoryExtracts the complete (including private) prop types from a prop factory function.
ExtractPublicPropTypesFromFactoryExtracts the public prop types from a prop factory function. Useful for obtaining the public prop interface from a factory that returns prop definitions.
ExtractSlotDefinitionsExtracts the slot definitions from a component with a slots property. Works with both components that have a slots property and direct SlotsType definitions.
FieldHookHandlerHandler type for field hooks that can be either a direct handler or a provider.
HookableEventsConverts emit validators/functions into hookable events with cleanup support. Each event gets a tuple of [callbackArgs, cleanupCallbackArgs] to support hook lifecycle.
IfAnyConditional type that returns Y if T is any, otherwise returns N.
InferPropTypeInfers the actual prop type from a Vue prop definition. Handles string/number/boolean constructors, prop objects with type, defaults, and more.
MergeDefaultMerges a prop type with a default value, making the prop type non-nullable.
MergeTypeDefaultMerges a prop type with a default value type. If no default is provided, returns just the prop type; otherwise returns the union.
NamedSlotParametersExtracts the parameter types from a named slot by name.
ObjectStrippedOfUndefinedValuesType utility that removes all keys with undefined values from an object type.
PartialKeysCreates a type where all keys are optional and values are unknown. Useful for partial key matching in conditional types.
PropFactoryA factory function type that creates prop definitions with optional defaults. Returns a function that takes optional defaults and returns props with those defaults applied.
ResolvedBasePropsResolved prop types with proper type inference from the BaseField props factory
SlotParametersExtracts the parameter types from a slot function.
UsePassthroughHookOptionsOptions for usePassthroughHook that control when and how a fallback is executed and how the produced handler is scheduled.
VFieldDefaultSlotPropsThe prop types for the default slot of Vuetify's VField component. Provides typed access to the props passed to VField's default slot, including field state, focus handlers, and validation status.

Utilities

FunctionDescription
isHTMLElementType guard that checks if a value is an HTMLElement. Safe to use in SSR environments.
isObjectType guard that checks if a value is a plain object (not null, not an array).
stripUndefinedValuesFromObjectRemoves all properties with undefined values from an object. This is useful for cleaning up objects before passing them to APIs or components that should not receive undefined values.
svgPathToIconValueConverts an SVG path string to an IconValue that can be used in Vuetify components.
useSlotRetrieves a slot from the slots object with proper typing.