Skip to content

Public Helpers

@nhtio/lucid-resourceful-vue-components/helpers

Utility functions, constants, and type helpers re-exported for application use. They fall into several groups: clipboard/UI utilities, color normalization, record rendering helpers, exception/factory helpers, object & string utilities, number formatting, field type helpers, and encoding / performance utilities.

Tip

Install the IoC plugin first (see Quickstart) so components using these helpers (e.g. record renderers) have required services.

Clipboard & DOM utilities

  • copyToClipboard — Copy text to the clipboard with optional feedback.
  • IN_BROWSER, SUPPORTS_INTERSECTION, SUPPORTS_RESIZE_OBSERVATION, SUPPORTS_VISUAL_VIEWPORT — Feature/environment flags for conditional UI logic.
  • extractErrorCode — Pull a normalized error code from HTTP exceptions / responses.
  • svgPathToIconValue — Convert raw SVG path data into a Vuetify icon value.

Record rendering helpers

  • renderDefaultResourcefulRecordForm — Programmatic renderer for a default record form layout.
  • renderResourcefulRecordModelPropertyField — Renders a field for a specific model property using schema metadata.

Color & styling helpers

  • getNormalizedBackgroundColor, getNormalizedForegroundColor — Normalize theme color inputs to consistent CSS values.
  • useNormalizedColor, useNormalizedColors, useNormalizedOpacities — Composables for reactive normalized colors & opacity sets.

Exceptions & factories

  • createError — Build a typed exception (code + message) used by higher-level components.
  • formatBigNumber — Format arbitrarily large numbers (Big.js) using Numeral.js‑style patterns (thousands, decimals, currency, percent, per‑mille, abbreviations, bytes, ordinals, forced sign, optional decimals).
  • getCamelAndMaybeKebabPropKeysFor — Produce camel + kebab prop keys for component factories.
  • getDefaultsForPropFactory — Read default values from a generated prop factory.

Object & string utilities

  • stripUndefinedValuesFromObject — Remove undefined entries (clean serialization).
  • getOxfordizedListParts — Break a list into parts for Oxford comma rendering.
  • getStringOrVNodeAsString — Safely stringify a string or VNode (for logging/alt text).
  • mergeClasses — Combine/class-normalize conditional class values.
  • toUnreactive — Freeze / detach reactive objects for non-reactive usage.
  • isNotEmpty — Truthy + length check for strings/arrays/objects.
  • makeIdentifier — Generate a stable random-ish identifier string.

Numbers & field types

  • asAbsInt — Coerce a number-like value to an absolute integer.
  • typeAndFormatToResourcefulFieldType, ResourcefulFieldType — Map between type/format combos and internal field type enum; exported constant & helper.

Encoding & performance helpers

  • encode, decode — Core encoding utilities (zlib/base64 pipeline) re-exported.
  • encodeValidator, decodeValidator — Joi schema encode/decode helpers for validation concerns.
  • debounce, throttle — Execution rate control wrappers for high-frequency events.

Types (selected)

Re-exported for convenience when building integrations/components:

  • Slot, SlotParameters, NamedSlotParameters, ExtractSlotDefinitions — Strongly typed Vue slots utilities.
  • CallbackFnResponse — Generic callback result container.
  • FactoryPropFactory, ExtractPublicDefaultPropTypes — Component prop factory typing helpers.
  • FocusProps — Common focus-related prop definitions.
  • EventProp — Typed event prop shape (generic).
  • ObjectStrippedOfUndefinedValues — Utility type after cleaning objects.
  • CreatedException — Result from createError.
  • ResourcefulFieldType — Field type enum constant.
    Link: ResourcefulFieldType
  • External: BigNumber (Big.js), RGB, ThemeDefinition — Re-exported external types for convenience.

When to reach for helpers

Use these helpers to avoid re-implementing common patterns: cleaning payloads, normalizing colors, rendering record fields, mapping type/format to field types, formatting large numbers, managing IDs, controlling async event rates, and encoding data for transport or validation.

They are intentionally small, pure (where possible), and safe to tree‑shake.