Create coupled parent-child component pairs with composition API.

Related tags

Vue.js vue-coupled
Overview

vue-coupled

Background

See discussion here.

This package serves as a POC that:

  • Allows any level of component encapsulation for child components.
  • Supports dynamically toggling children with v-if and re-ordering with v-for.
  • Support TypeScript.
  • Whose implementation details are abstracted away from the consumer components.

Usage

npm i --save vue-coupled

eg. A <Select> / <Option> couple:

option-group.ts

import { createCoupled } from 'vue-coupled'

type Option = {
  value: string
  label: string
  disabled?: boolean
}

export const { useParent, useChild } = createCoupled<Option>()

Select.vue

<script setup lang="ts">
import { useParent } from './option-group'

const children = useParent()

// children will be a shallow ref for the reactive options array, whose
// option data is provided by the `Option` component via `useChild`
</script>

Option.vue

<script setup lang="ts">
import { useChild } from './option-group'

// Vue doesn't support imported type in defineProps transformation yet
type Option = {
  value: string
  label: string
  disabled?: boolean
}

const props = defineProps<Option>()

useChild(props)
</script>
You might also like...

A text replacer component for vue3.

A text replacer component for Vue 3. Requires Vue 3 as peer-dependency. Installation Install it from npm. npm install vue3-replacer pnpm add vue3-rep

Feb 19, 2022

🛰 Shared component across routes with animations

🛰 Shared component across routes with animations

Shared Vue component across routes with animations Live Demo Why? It's quite common you might have a same component used in different routes (pages) w

Jan 4, 2023

🏝 Opinionated Web Components Starter template to help kick-start development of a cross-framework component library.

Web Component Library Starter Kit "Why create components for a specific framework when it can be written to be understood by all — including browsers?

Dec 24, 2022

🏝 Opinionated Web Components Starter template to help kick-start development of a cross-framework component library.

Web Component Library Starter Kit "Why create components for a specific framework when it can be written to be understood by all — including browsers?

May 1, 2022

This package allows you to show a placeholder-component while inertia fetches the content of ne new page while routing

inertia vue placeholder middleware This package adds a component placeholder middleware for inertia vue. instead of the InertiaProgressBar you can sho

Jul 24, 2022

:necktie: :briefcase: Build fast :rocket: and easy multiple beautiful resumes and create your best CV ever! Made with Vue and LESS.

:necktie: :briefcase: Build fast :rocket: and easy multiple beautiful resumes and create your best CV ever! Made with Vue and LESS.

best-resume-ever 👔 💼 Build fast 🚀 and easy multiple beautiful resumes and create your best CV ever! Made with Vue and LESS. Cool Creative Green Pur

Jan 9, 2023

Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

Jan 4, 2023

tsParticles - Easily create highly customizable particles animations and use them as animated backgrounds for your website. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno.

tsParticles - Easily create highly customizable particles animations and use them as animated backgrounds for your website. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno.

tsParticles - TypeScript Particles A lightweight TypeScript library for creating particles. Dependency free (*) and browser ready! Particles.js conver

Jan 4, 2023

Create conversational conditional-logic forms with Vue.js.

Create conversational conditional-logic forms with Vue.js.

Vue Flow Form Create conversational conditional-logic forms with Vue.js. Live Demos Questionnaire example Support page example Quiz example Project Do

Jan 4, 2023
Owner
GU Yiling
For the web.
GU Yiling
Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template.

vue2-shortcut Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template. Install $ npm install --save vu

Graxi 37 Aug 14, 2022
A API documentation generator for Vue3 single file component.

doc-vue A API documentation generator for Vue3 single file component. Table of Contents Installation Write API Description Command Line Usage Programm

annnhan 36 Oct 20, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.9k Jan 9, 2023
🐉 Material Component Framework for Vue

Supporting Vuetify Vuetify is a MIT licensed project that is developed and maintained full-time by John Leider and Heather Leider; with support from t

vuetify 36.2k Jan 3, 2023
Universal select/multiselect/tagging component for Vue.js

vue-multiselect Probably the most complete selecting solution for Vue.js 2.0, without jQuery. Documentation Visit: vue-multiselect.js.org Sponsors Gol

Damian Dulisz 6.3k Jan 6, 2023