@globalbrain/sefirot 3.9.0 → 3.10.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.
@@ -0,0 +1,58 @@
1
+ import { type Ref, ref } from 'vue'
2
+
3
+ export interface Power {
4
+ state: Ref<boolean>
5
+ on(fn?: () => void): boolean
6
+ onAfter(fn: () => Promise<any>): Promise<boolean>
7
+ off(fn?: () => void): boolean
8
+ offAfter(fn: () => Promise<any>): Promise<boolean>
9
+ toggle(fn?: () => void): boolean
10
+ toggleAfter(fn: () => Promise<any>): Promise<boolean>
11
+ }
12
+
13
+ export function usePower(initialValue = false): Power {
14
+ const state = ref(initialValue)
15
+
16
+ function on(fn: () => void = () => {}): boolean {
17
+ typeof fn === 'function' && fn()
18
+ state.value = true
19
+ return state.value
20
+ }
21
+
22
+ async function onAfter(fn: () => Promise<any>): Promise<boolean> {
23
+ await fn()
24
+ return on()
25
+ }
26
+
27
+ function off(fn: () => void = () => {}): boolean {
28
+ typeof fn === 'function' && fn()
29
+ state.value = false
30
+ return state.value
31
+ }
32
+
33
+ async function offAfter(fn: () => Promise<any>): Promise<boolean> {
34
+ await fn()
35
+ return off()
36
+ }
37
+
38
+ function toggle(fn: () => void = () => {}): boolean {
39
+ typeof fn === 'function' && fn()
40
+ state.value = !state.value
41
+ return state.value
42
+ }
43
+
44
+ async function toggleAfter(fn: () => Promise<any>): Promise<boolean> {
45
+ await fn()
46
+ return toggle()
47
+ }
48
+
49
+ return {
50
+ state,
51
+ on,
52
+ onAfter,
53
+ off,
54
+ offAfter,
55
+ toggle,
56
+ toggleAfter
57
+ }
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "packageManager": "pnpm@8.11.0",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",