@aoao-y33/hooks 0.0.1

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/README.md ADDED
@@ -0,0 +1,44 @@
1
+ ## 功能特性
2
+
3
+ - 🚀 基于 Vue 3 Composition API
4
+ - 📦 TypeScript 原生支持,完整类型定义
5
+ - 🔄 状态管理简化
6
+
7
+ ## API 文档
8
+
9
+ ### useState(initValue)
10
+
11
+ 创建一个响应式状态,并提供便捷的更新方法。支持直接替换和深度合并两种更新模式。
12
+
13
+ **参数:**
14
+ - `initValue` (T) - 初始值,可以是任意类型
15
+
16
+ **返回值:**
17
+ - `[state, setState]` - 元组类型
18
+ - `state` (Ref<T>) - 响应式引用
19
+ - `setState` (function) - 状态更新函数
20
+
21
+ **setState 参数:**
22
+ - `value` (Partial<T> | T) - 新的状态值
23
+ - `write` (boolean, 可选) - 更新模式
24
+ - `false` (默认): 深度合并模式,将新值与现有状态深度合并
25
+ - `true`: 直接替换模式,完全替换现有状态
26
+
27
+ **示例:**
28
+
29
+
30
+ ```vue
31
+ <script setup lang="ts">
32
+ import { useState } from '@aoaoy33/hooks'
33
+ const [user, setUser] = useState({ name: 'John', age: 25, address: { city: 'Beijing', zip: '100000' } })
34
+ setUser({ name: 'Jane', age: 30 }, true)
35
+ </script>
36
+ <template>
37
+ <div>
38
+ <p>Count: {{ count }}</p>
39
+ <button @click="setCount(count + 1)">Increment</button>
40
+ <p>User: {{ user.name }}, Age: {{ user.age }}</p>
41
+ <button @click="setUser({ age: user.age + 1 })">Increase Age</button>
42
+ </div>
43
+ </template>
44
+ ```
@@ -0,0 +1,3 @@
1
+ import { Ref } from 'vue';
2
+ export declare function useState<T>(initValue: T): readonly [Ref<T, T>, (value: Partial<T> | T, write?: boolean) => void];
3
+ //# sourceMappingURL=useState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../../src/core/useState.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,GAAG,EAAM,MAAM,KAAK,CAAC;AAElC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,gCAEX,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,UAAS,OAAO,WAQ1D"}
@@ -0,0 +1,2 @@
1
+ export * from './core/useState';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}