All Projects → pikax → Vue Composable

pikax / Vue Composable

Licence: mit
Vue composition-api composable components. i18n, validation, pagination, fetch, etc. +50 different composables

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vue Composable

React Table
⚛️ Hooks for building fast and extendable tables and datagrids for React
Stars: ✭ 15,739 (+2366.93%)
Mutual labels:  hooks, pagination
Next Purescript Example
Simple example app using Next.js with Purescript
Stars: ✭ 35 (-94.51%)
Mutual labels:  hooks, tailwindcss
Usetheform
React library for composing declarative forms, manage their state, handling their validation and much more.
Stars: ✭ 40 (-93.73%)
Mutual labels:  hooks, validation
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (-65.2%)
Mutual labels:  hooks, validation
Vue Use Web
🕸 Web APIs implemented as Vue.js composition functions
Stars: ✭ 603 (-5.49%)
Mutual labels:  hooks, utility-library
React Fetch Hook
React hook for conveniently use Fetch API
Stars: ✭ 285 (-55.33%)
Mutual labels:  hooks, pagination
Events-based-organizational-website
The official codebase for college-based (event managing) organizations. FOUR-LEVEL Authorization system and scalable.
Stars: ✭ 14 (-97.81%)
Mutual labels:  validation, tailwindcss
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+3792.01%)
Mutual labels:  hooks, validation
Vue Mc
Models and Collections for Vue
Stars: ✭ 588 (-7.84%)
Mutual labels:  validation
Vue Form
Form validation for Vue.js 2.2+
Stars: ✭ 618 (-3.13%)
Mutual labels:  validation
Tailwindcss Figma Kit
Figma Kit for TailwindCSS
Stars: ✭ 577 (-9.56%)
Mutual labels:  tailwindcss
Vvalidator
🤖 An easy to use form validator for Kotlin & Android.
Stars: ✭ 592 (-7.21%)
Mutual labels:  validation
Ng2 Validation
angular2 validation
Stars: ✭ 622 (-2.51%)
Mutual labels:  validation
Nice Validator
Simple, smart and pleasant validation solution.
Stars: ✭ 587 (-7.99%)
Mutual labels:  validation
Marshmallow
A lightweight library for converting complex objects to and from simple Python datatypes.
Stars: ✭ 5,857 (+818.03%)
Mutual labels:  validation
Tables
Bulma themed, VueJS powered Datatable with server-side loading and JSON template setup
Stars: ✭ 575 (-9.87%)
Mutual labels:  pagination
Pluggy
A minimalist production ready plugin system
Stars: ✭ 572 (-10.34%)
Mutual labels:  hooks
Intl Tel Input
A JavaScript plugin for entering and validating international telephone numbers
Stars: ✭ 5,963 (+834.64%)
Mutual labels:  validation
X.pagedlist
Library for easily paging through any IEnumerable/IQueryable in ASP.NET/ASP.NET Core
Stars: ✭ 625 (-2.04%)
Mutual labels:  pagination
Tailwindo
🔌 Convert Bootstrap CSS code to Tailwind CSS code
Stars: ✭ 606 (-5.02%)
Mutual labels:  tailwindcss

vue-composable

vue-composable logo

CircleCI Coverage Status npm version bundle size

Out-of-the-box ready to use composables

  • 🌴 TreeShakable
  • 🧙‍♂️ Fully Typescript
  • 💚 Vue 3 and 2 support
  • 🔨 Vue Devtools support

Introduction

This library aim is to be one stop shop for many real-world composable functions, with aggressive tree-shaking to keep it light on your end code.

Installing

# @vue/composition-api

# install with yarn
yarn add @vue/composition-api vue-composable

# install with npm
npm install @vue/composition-api vue-composable

# vue 3

# install with yarn
yarn add vue-composable

# install with npm
npm install vue-composable

Documentation

Check our documentation

Composable

Event

  • Event - Attach event listener to a DOM element
  • Mouse Move - Attach mousemove listener to a DOM element
  • Resize - Attach resize listener to a DOM element
  • Scroll - Attach scroll listener to a DOM element
  • onOutsidePress - Execute callback when click is outside of element

Dom

Date

  • useNow : Return reactive custom timer with specified refresh rate
  • useDateNow : Returns reactive Date.now() with custom refresh rate
  • usePerformanceNow : Returns reactive performance.now() with custom refresh rate

Format

  • format - Reactive string format
  • path - Retrieve object value based on string path

Breakpoint

MISC

Storage

  • WebStorage - Reactive access to Storage API, useLocalStorage and useSessionStorage use this
  • storage - uses localStorage or on safari private it uses sessionStorage
  • localStorage - Reactive access to a localStorage
  • sessionStorage - Reactive access to a sessionStorage

Pagination

Validation

i18n

  • i18n - Simple i18n implementation with API inspired by vue-i18n

Intl

Promise

Meta

  • Title - reactive document.title

State

  • Timeline - Tracks variable history
  • Undo - Tracks variable history, to allow undo and redo
  • valueSync - syncs variables value, across multiple refs

Web

External

New packages needed

Information

This is a monorepo project, please check packages

Devtools

There's some experimental devtools support starting from 1.0.0-beta.6, only available for vue-next and devtools beta 6.

Install plugin

To use devtools you need to install the plugin first:

import { createApp } from "vue";
import { VueComposableDevtools } from "vue-composable";
import App from "./App.vue";

const app = createApp(App);
app.use(VueComposableDevtools);
// or
app.use(VueComposableDevtools, {
  id: "vue-composable",
  label: "devtool composables",
});

app.mount("#app");

Component State

To add properties to the component inspector tab ComponentState

const bar = "bar";
useDevtoolsComponentState(
  {
    bar,
  },
  {
    type: "custom composable", // change group
  }
);

const baz = () => "baz";
useDevtoolsComponentState({ baz });
// no duplicates added by default
useDevtoolsComponentState({ baz });

const the = 42;
useDevtoolsComponentState({ the });
// to allow multiple same key
useDevtoolsComponentState({ the }, { duplicate: true });

// use a devtools api list directly
interface StateBase {
  key: string;
  value: any;
  editable: boolean;
  objectType?: "ref" | "reactive" | "computed" | "other";
  raw?: string;
  type?: string;
}
useDevtoolsComponentState([
  {
    key: "_bar",
    type: "direct",
    value: "bar",
    editable: true,
  },
  {
    key: "_baz",
    type: "direct",
    value: "baz",
    editable: false,
  },
]);

// raw change
useDevtoolsComponentState((payload, ctx) => {
  payload.state.push(
    ...[
      {
        key: "_bar",
        type: "raw",
        value: "bar",
        editable: true,
      },
      {
        key: "_baz",
        type: "raw",
        value: "baz",
        editable: false,
      },
    ]
  );
});

Timeline events

To add timeline events:

const id = "vue-composable";
const label = "Test events";
const color = 0x92a2bf;

const { addEvent, pushEvent } = useDevtoolsTimelineLayer(
  id,
  description,
  color
);

// adds event to a specific point in the timeline
addEvent({
  time: Date.now(),
  data: {
    // data object
  },
  meta: {
    // meta object
  },
});

// adds event with `time: Date.now()`
pushEvent({
  data: {
    // data object
  },
  meta: {
    // meta object
  },
});

Inspector

Allows to create a new inspector for your data.

I'm still experimenting on how to expose this API on a composable, this will likely to change in the future, suggestions are welcome.

useDevtoolsInspector(
  {
    id: "vue-composable",
    label: "test vue-composable",
  },
  // list of nodes, this can be reactive
  [
    {
      id: "test",
      label: "test - vue-composable",
      depth: 0,
      state: {
        composable: [
          {
            editable: false,
            key: "count",
            objectType: "Ref",
            type: "setup",
            value: myRefValue,
          },
        ],
      },
    },
  ]
);

Typescript

[email protected] is not supported, the supported version can be checked on package.json, usually is the latest version or the same major as vue-3

Contributing

You can contribute raising issues and by helping out with code.

Tests and Documentation are the most important things for me, because good documentation is really useful!

I really appreciate some tweaks or changes on how the documentation is displayed and how to make it easier to read.

Twitter: @pikax_dev

Build

# install packages
yarn

# build and test for v2
yarn build --version=2
yarn test:vue2

# build and test for v3
yarn build
yarn test

New composable

  1. Fork it!
  2. Create your feature branch: git checkout -b feat/new-composable
  3. Commit your changes: git commit -am 'feat(composable): add a new composable'
  4. Push to the branch: git push origin feat/new-composable
  5. Submit a pull request

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].