@pistachiojs/vue 0.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pistachio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @pistachiojs/vue
|
|
2
|
+
|
|
3
|
+
A collection Vue composables library for reactive programming tasks. Built on top of @pistachiojs/core packages.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pistachiojs/vue)
|
|
6
|
+
[](../../coverage)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
## Key features
|
|
10
|
+
|
|
11
|
+
- **Full type safety** - TypeScript-first with complete inference
|
|
12
|
+
- **Vue optimized** - Built specifically for Vue 3+
|
|
13
|
+
- **Tree shakeable** - Modular imports for minimal bundle size
|
|
14
|
+
- **Well tested** - Comprehensive test coverage
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# npm
|
|
20
|
+
npm install @pistachiojs/core @pistachiojs/vue
|
|
21
|
+
|
|
22
|
+
# pnpm
|
|
23
|
+
pnpm add @pistachiojs/core @pistachiojs/vue
|
|
24
|
+
|
|
25
|
+
# yarn
|
|
26
|
+
yarn add @pistachiojs/core @pistachiojs/vue
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import { useCounter } from '@pistachiojs/vue'
|
|
34
|
+
|
|
35
|
+
const { count, increment, decrement, set, reset } = useCounter(0, {
|
|
36
|
+
min: 0,
|
|
37
|
+
max: 10,
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div>
|
|
43
|
+
<p>Count: {{ count }}</p>
|
|
44
|
+
<button @click="increment">+</button>
|
|
45
|
+
<button @click="decrement">-</button>
|
|
46
|
+
<button @click="() => set(5)">Set to 5</button>
|
|
47
|
+
<button @click="reset">Reset</button>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Type safety
|
|
53
|
+
|
|
54
|
+
This package is written in TypeScript and includes type definitions out of the box.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { useCounter } from '@pistachiojs/vue'
|
|
58
|
+
|
|
59
|
+
// Full type inference
|
|
60
|
+
const { count, increment, decrement, set, reset } = useCounter(0, { min: 0, max: 100 })
|
|
61
|
+
// count: Ref<number>
|
|
62
|
+
// increment: () => void
|
|
63
|
+
// decrement: () => void
|
|
64
|
+
// set: (value: number) => void
|
|
65
|
+
// reset: () => void
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT © [Dirga Prakesha](https://github.com/dirgaprksha)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
interface UseCounterOptions {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
}
|
|
7
|
+
interface UseCounterReturn {
|
|
8
|
+
count: Ref<number>;
|
|
9
|
+
increment: () => void;
|
|
10
|
+
decrement: () => void;
|
|
11
|
+
set: (value: number) => void;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Vue composable to manage counter state with optional min and max bounds.
|
|
16
|
+
* @param initialValue - Number value for initial.
|
|
17
|
+
* @param options - Configuration object.
|
|
18
|
+
* @returns Object containing reactive count and handler methods.
|
|
19
|
+
*/
|
|
20
|
+
declare function useCounter(initialValue?: number, options?: UseCounterOptions): UseCounterReturn;
|
|
21
|
+
|
|
22
|
+
export { useCounter };
|
|
23
|
+
export type { UseCounterOptions, UseCounterReturn };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as o}from"vue";function u(r,a,e){return Math.min(Math.max(r,a),e)}function c(r=0,a={}){const{min:e=-1/0,max:n=1/0}=a,t=o(u(r,e,n));return{count:t,increment:()=>{t.value=u(t.value+1,e,n)},decrement:()=>{t.value=u(t.value-1,e,n)},set:m=>{t.value=u(m,e,n)},reset:()=>{t.value=u(r,e,n)}}}export{c as useCounter};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=require("vue");function n(r,a,e){return Math.min(Math.max(r,a),e)}function i(r=0,a={}){const{min:e=-1/0,max:t=1/0}=a,u=c.ref(n(r,e,t));return{count:u,increment:()=>{u.value=n(u.value+1,e,t)},decrement:()=>{u.value=n(u.value-1,e,t)},set:v=>{u.value=n(v,e,t)},reset:()=>{u.value=n(r,e,t)}}}exports.useCounter=i;
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pistachiojs/vue",
|
|
3
|
+
"description": "A Vue composables library for reactive programming tasks",
|
|
4
|
+
"version": "0.1.0-dev.0",
|
|
5
|
+
"author": "Dirga Prakesha <dirga.prakesha@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dirgaprksha/pistachio.git",
|
|
10
|
+
"directory": "packages/vue"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"utility",
|
|
14
|
+
"typescript",
|
|
15
|
+
"javascript",
|
|
16
|
+
"helpers",
|
|
17
|
+
"functional",
|
|
18
|
+
"vue",
|
|
19
|
+
"type-safe",
|
|
20
|
+
"tree-shakeable"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"module": "dist/index.esm.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/index.js",
|
|
28
|
+
"dist/index.esm.js",
|
|
29
|
+
"dist/index.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": ">=3"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@pistachiojs/core": "0.3.0-dev.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rollup -c ../../rollup.config.mjs --environment TARGET:vue",
|
|
39
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
40
|
+
"clean": "rimraf node_modules dist"
|
|
41
|
+
}
|
|
42
|
+
}
|