@vueuse/skills 14.2.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 +643 -0
- package/package.json +36 -0
- package/skills/vueuse-functions/SKILL.md +417 -0
- package/skills/vueuse-functions/references/computedAsync.md +195 -0
- package/skills/vueuse-functions/references/computedEager.md +62 -0
- package/skills/vueuse-functions/references/computedInject.md +137 -0
- package/skills/vueuse-functions/references/computedWithControl.md +98 -0
- package/skills/vueuse-functions/references/createEventHook.md +86 -0
- package/skills/vueuse-functions/references/createGenericProjection.md +25 -0
- package/skills/vueuse-functions/references/createGlobalState.md +95 -0
- package/skills/vueuse-functions/references/createInjectionState.md +215 -0
- package/skills/vueuse-functions/references/createProjection.md +31 -0
- package/skills/vueuse-functions/references/createRef.md +54 -0
- package/skills/vueuse-functions/references/createReusableTemplate.md +356 -0
- package/skills/vueuse-functions/references/createSharedComposable.md +42 -0
- package/skills/vueuse-functions/references/createTemplatePromise.md +306 -0
- package/skills/vueuse-functions/references/createUnrefFn.md +51 -0
- package/skills/vueuse-functions/references/extendRef.md +76 -0
- package/skills/vueuse-functions/references/from.md +80 -0
- package/skills/vueuse-functions/references/get.md +30 -0
- package/skills/vueuse-functions/references/injectLocal.md +35 -0
- package/skills/vueuse-functions/references/isDefined.md +31 -0
- package/skills/vueuse-functions/references/logicAnd.md +40 -0
- package/skills/vueuse-functions/references/logicNot.md +36 -0
- package/skills/vueuse-functions/references/logicOr.md +40 -0
- package/skills/vueuse-functions/references/makeDestructurable.md +41 -0
- package/skills/vueuse-functions/references/onClickOutside.md +221 -0
- package/skills/vueuse-functions/references/onElementRemoval.md +88 -0
- package/skills/vueuse-functions/references/onKeyStroke.md +211 -0
- package/skills/vueuse-functions/references/onLongPress.md +227 -0
- package/skills/vueuse-functions/references/onStartTyping.md +53 -0
- package/skills/vueuse-functions/references/provideLocal.md +37 -0
- package/skills/vueuse-functions/references/reactify.md +144 -0
- package/skills/vueuse-functions/references/reactifyObject.md +62 -0
- package/skills/vueuse-functions/references/reactiveComputed.md +34 -0
- package/skills/vueuse-functions/references/reactiveOmit.md +86 -0
- package/skills/vueuse-functions/references/reactivePick.md +106 -0
- package/skills/vueuse-functions/references/refAutoReset.md +46 -0
- package/skills/vueuse-functions/references/refDebounced.md +81 -0
- package/skills/vueuse-functions/references/refDefault.md +36 -0
- package/skills/vueuse-functions/references/refManualReset.md +44 -0
- package/skills/vueuse-functions/references/refThrottled.md +99 -0
- package/skills/vueuse-functions/references/refWithControl.md +146 -0
- package/skills/vueuse-functions/references/set.md +30 -0
- package/skills/vueuse-functions/references/syncRef.md +195 -0
- package/skills/vueuse-functions/references/syncRefs.md +128 -0
- package/skills/vueuse-functions/references/templateRef.md +86 -0
- package/skills/vueuse-functions/references/toObserver.md +38 -0
- package/skills/vueuse-functions/references/toReactive.md +41 -0
- package/skills/vueuse-functions/references/toRef.md +75 -0
- package/skills/vueuse-functions/references/toRefs.md +81 -0
- package/skills/vueuse-functions/references/tryOnBeforeMount.md +34 -0
- package/skills/vueuse-functions/references/tryOnBeforeUnmount.md +32 -0
- package/skills/vueuse-functions/references/tryOnMounted.md +34 -0
- package/skills/vueuse-functions/references/tryOnScopeDispose.md +31 -0
- package/skills/vueuse-functions/references/tryOnUnmounted.md +32 -0
- package/skills/vueuse-functions/references/unrefElement.md +54 -0
- package/skills/vueuse-functions/references/until.md +161 -0
- package/skills/vueuse-functions/references/useAbs.md +31 -0
- package/skills/vueuse-functions/references/useActiveElement.md +85 -0
- package/skills/vueuse-functions/references/useAnimate.md +181 -0
- package/skills/vueuse-functions/references/useArrayDifference.md +84 -0
- package/skills/vueuse-functions/references/useArrayEvery.md +59 -0
- package/skills/vueuse-functions/references/useArrayFilter.md +63 -0
- package/skills/vueuse-functions/references/useArrayFind.md +50 -0
- package/skills/vueuse-functions/references/useArrayFindIndex.md +59 -0
- package/skills/vueuse-functions/references/useArrayFindLast.md +52 -0
- package/skills/vueuse-functions/references/useArrayIncludes.md +63 -0
- package/skills/vueuse-functions/references/useArrayJoin.md +74 -0
- package/skills/vueuse-functions/references/useArrayMap.md +59 -0
- package/skills/vueuse-functions/references/useArrayReduce.md +81 -0
- package/skills/vueuse-functions/references/useArraySome.md +59 -0
- package/skills/vueuse-functions/references/useArrayUnique.md +76 -0
- package/skills/vueuse-functions/references/useAsyncQueue.md +136 -0
- package/skills/vueuse-functions/references/useAsyncState.md +185 -0
- package/skills/vueuse-functions/references/useAsyncValidator.md +70 -0
- package/skills/vueuse-functions/references/useAuth.md +123 -0
- package/skills/vueuse-functions/references/useAverage.md +36 -0
- package/skills/vueuse-functions/references/useAxios.md +322 -0
- package/skills/vueuse-functions/references/useBase64.md +136 -0
- package/skills/vueuse-functions/references/useBattery.md +78 -0
- package/skills/vueuse-functions/references/useBluetooth.md +175 -0
- package/skills/vueuse-functions/references/useBreakpoints.md +172 -0
- package/skills/vueuse-functions/references/useBroadcastChannel.md +74 -0
- package/skills/vueuse-functions/references/useBrowserLocation.md +83 -0
- package/skills/vueuse-functions/references/useCached.md +52 -0
- package/skills/vueuse-functions/references/useCeil.md +31 -0
- package/skills/vueuse-functions/references/useChangeCase.md +79 -0
- package/skills/vueuse-functions/references/useClamp.md +85 -0
- package/skills/vueuse-functions/references/useClipboard.md +123 -0
- package/skills/vueuse-functions/references/useClipboardItems.md +94 -0
- package/skills/vueuse-functions/references/useCloned.md +91 -0
- package/skills/vueuse-functions/references/useColorMode.md +172 -0
- package/skills/vueuse-functions/references/useConfirmDialog.md +159 -0
- package/skills/vueuse-functions/references/useCookies.md +162 -0
- package/skills/vueuse-functions/references/useCountdown.md +105 -0
- package/skills/vueuse-functions/references/useCounter.md +86 -0
- package/skills/vueuse-functions/references/useCssSupports.md +35 -0
- package/skills/vueuse-functions/references/useCssVar.md +50 -0
- package/skills/vueuse-functions/references/useCurrentElement.md +61 -0
- package/skills/vueuse-functions/references/useCycleList.md +75 -0
- package/skills/vueuse-functions/references/useDark.md +144 -0
- package/skills/vueuse-functions/references/useDateFormat.md +145 -0
- package/skills/vueuse-functions/references/useDebounceFn.md +100 -0
- package/skills/vueuse-functions/references/useDebouncedRefHistory.md +40 -0
- package/skills/vueuse-functions/references/useDeviceMotion.md +86 -0
- package/skills/vueuse-functions/references/useDeviceOrientation.md +62 -0
- package/skills/vueuse-functions/references/useDevicePixelRatio.md +44 -0
- package/skills/vueuse-functions/references/useDevicesList.md +90 -0
- package/skills/vueuse-functions/references/useDisplayMedia.md +71 -0
- package/skills/vueuse-functions/references/useDocumentVisibility.md +45 -0
- package/skills/vueuse-functions/references/useDraggable.md +317 -0
- package/skills/vueuse-functions/references/useDrauu.md +65 -0
- package/skills/vueuse-functions/references/useDropZone.md +83 -0
- package/skills/vueuse-functions/references/useElementBounding.md +131 -0
- package/skills/vueuse-functions/references/useElementByPoint.md +48 -0
- package/skills/vueuse-functions/references/useElementHover.md +79 -0
- package/skills/vueuse-functions/references/useElementSize.md +78 -0
- package/skills/vueuse-functions/references/useElementVisibility.md +123 -0
- package/skills/vueuse-functions/references/useEventBus.md +101 -0
- package/skills/vueuse-functions/references/useEventListener.md +226 -0
- package/skills/vueuse-functions/references/useEventSource.md +204 -0
- package/skills/vueuse-functions/references/useExtractedObservable.md +198 -0
- package/skills/vueuse-functions/references/useEyeDropper.md +71 -0
- package/skills/vueuse-functions/references/useFavicon.md +67 -0
- package/skills/vueuse-functions/references/useFetch.md +546 -0
- package/skills/vueuse-functions/references/useFileDialog.md +91 -0
- package/skills/vueuse-functions/references/useFileSystemAccess.md +162 -0
- package/skills/vueuse-functions/references/useFirestore.md +129 -0
- package/skills/vueuse-functions/references/useFloor.md +31 -0
- package/skills/vueuse-functions/references/useFocus.md +99 -0
- package/skills/vueuse-functions/references/useFocusTrap.md +245 -0
- package/skills/vueuse-functions/references/useFocusWithin.md +57 -0
- package/skills/vueuse-functions/references/useFps.md +28 -0
- package/skills/vueuse-functions/references/useFullscreen.md +75 -0
- package/skills/vueuse-functions/references/useFuse.md +107 -0
- package/skills/vueuse-functions/references/useGamepad.md +222 -0
- package/skills/vueuse-functions/references/useGeolocation.md +85 -0
- package/skills/vueuse-functions/references/useIDBKeyval.md +93 -0
- package/skills/vueuse-functions/references/useIdle.md +88 -0
- package/skills/vueuse-functions/references/useImage.md +86 -0
- package/skills/vueuse-functions/references/useInfiniteScroll.md +157 -0
- package/skills/vueuse-functions/references/useIntersectionObserver.md +118 -0
- package/skills/vueuse-functions/references/useInterval.md +112 -0
- package/skills/vueuse-functions/references/useIntervalFn.md +50 -0
- package/skills/vueuse-functions/references/useIpcRenderer.md +144 -0
- package/skills/vueuse-functions/references/useIpcRendererInvoke.md +58 -0
- package/skills/vueuse-functions/references/useIpcRendererOn.md +52 -0
- package/skills/vueuse-functions/references/useJwt.md +57 -0
- package/skills/vueuse-functions/references/useKeyModifier.md +87 -0
- package/skills/vueuse-functions/references/useLastChanged.md +63 -0
- package/skills/vueuse-functions/references/useLocalStorage.md +41 -0
- package/skills/vueuse-functions/references/useMagicKeys.md +245 -0
- package/skills/vueuse-functions/references/useManualRefHistory.md +204 -0
- package/skills/vueuse-functions/references/useMath.md +47 -0
- package/skills/vueuse-functions/references/useMax.md +36 -0
- package/skills/vueuse-functions/references/useMediaControls.md +571 -0
- package/skills/vueuse-functions/references/useMediaQuery.md +53 -0
- package/skills/vueuse-functions/references/useMemoize.md +175 -0
- package/skills/vueuse-functions/references/useMemory.md +71 -0
- package/skills/vueuse-functions/references/useMin.md +36 -0
- package/skills/vueuse-functions/references/useMounted.md +38 -0
- package/skills/vueuse-functions/references/useMouse.md +113 -0
- package/skills/vueuse-functions/references/useMouseInElement.md +123 -0
- package/skills/vueuse-functions/references/useMousePressed.md +112 -0
- package/skills/vueuse-functions/references/useMutationObserver.md +61 -0
- package/skills/vueuse-functions/references/useNProgress.md +78 -0
- package/skills/vueuse-functions/references/useNavigatorLanguage.md +57 -0
- package/skills/vueuse-functions/references/useNetwork.md +106 -0
- package/skills/vueuse-functions/references/useNow.md +79 -0
- package/skills/vueuse-functions/references/useObjectUrl.md +55 -0
- package/skills/vueuse-functions/references/useObservable.md +91 -0
- package/skills/vueuse-functions/references/useOffsetPagination.md +199 -0
- package/skills/vueuse-functions/references/useOnline.md +41 -0
- package/skills/vueuse-functions/references/usePageLeave.md +42 -0
- package/skills/vueuse-functions/references/useParallax.md +58 -0
- package/skills/vueuse-functions/references/useParentElement.md +54 -0
- package/skills/vueuse-functions/references/usePerformanceObserver.md +48 -0
- package/skills/vueuse-functions/references/usePermission.md +79 -0
- package/skills/vueuse-functions/references/usePointer.md +89 -0
- package/skills/vueuse-functions/references/usePointerLock.md +60 -0
- package/skills/vueuse-functions/references/usePointerSwipe.md +80 -0
- package/skills/vueuse-functions/references/usePrecision.md +49 -0
- package/skills/vueuse-functions/references/usePreferredColorScheme.md +42 -0
- package/skills/vueuse-functions/references/usePreferredContrast.md +42 -0
- package/skills/vueuse-functions/references/usePreferredDark.md +41 -0
- package/skills/vueuse-functions/references/usePreferredLanguages.md +41 -0
- package/skills/vueuse-functions/references/usePreferredReducedMotion.md +42 -0
- package/skills/vueuse-functions/references/usePreferredReducedTransparency.md +42 -0
- package/skills/vueuse-functions/references/usePrevious.md +40 -0
- package/skills/vueuse-functions/references/useProjection.md +38 -0
- package/skills/vueuse-functions/references/useQRCode.md +53 -0
- package/skills/vueuse-functions/references/useRTDB.md +83 -0
- package/skills/vueuse-functions/references/useRafFn.md +68 -0
- package/skills/vueuse-functions/references/useRefHistory.md +285 -0
- package/skills/vueuse-functions/references/useResizeObserver.md +109 -0
- package/skills/vueuse-functions/references/useRound.md +31 -0
- package/skills/vueuse-functions/references/useRouteHash.md +27 -0
- package/skills/vueuse-functions/references/useRouteParams.md +38 -0
- package/skills/vueuse-functions/references/useRouteQuery.md +79 -0
- package/skills/vueuse-functions/references/useSSRWidth.md +47 -0
- package/skills/vueuse-functions/references/useScreenOrientation.md +96 -0
- package/skills/vueuse-functions/references/useScreenSafeArea.md +60 -0
- package/skills/vueuse-functions/references/useScriptTag.md +116 -0
- package/skills/vueuse-functions/references/useScroll.md +238 -0
- package/skills/vueuse-functions/references/useScrollLock.md +66 -0
- package/skills/vueuse-functions/references/useSessionStorage.md +41 -0
- package/skills/vueuse-functions/references/useShare.md +68 -0
- package/skills/vueuse-functions/references/useSortable.md +235 -0
- package/skills/vueuse-functions/references/useSorted.md +90 -0
- package/skills/vueuse-functions/references/useSpeechRecognition.md +94 -0
- package/skills/vueuse-functions/references/useSpeechSynthesis.md +105 -0
- package/skills/vueuse-functions/references/useStepper.md +137 -0
- package/skills/vueuse-functions/references/useStorage.md +278 -0
- package/skills/vueuse-functions/references/useStorageAsync.md +136 -0
- package/skills/vueuse-functions/references/useStyleTag.md +131 -0
- package/skills/vueuse-functions/references/useSubject.md +77 -0
- package/skills/vueuse-functions/references/useSubscription.md +33 -0
- package/skills/vueuse-functions/references/useSum.md +36 -0
- package/skills/vueuse-functions/references/useSupported.md +29 -0
- package/skills/vueuse-functions/references/useSwipe.md +75 -0
- package/skills/vueuse-functions/references/useTemplateRefsList.md +37 -0
- package/skills/vueuse-functions/references/useTextDirection.md +75 -0
- package/skills/vueuse-functions/references/useTextSelection.md +40 -0
- package/skills/vueuse-functions/references/useTextareaAutosize.md +97 -0
- package/skills/vueuse-functions/references/useThrottleFn.md +57 -0
- package/skills/vueuse-functions/references/useThrottledRefHistory.md +47 -0
- package/skills/vueuse-functions/references/useTimeAgo.md +154 -0
- package/skills/vueuse-functions/references/useTimeAgoIntl.md +117 -0
- package/skills/vueuse-functions/references/useTimeout.md +113 -0
- package/skills/vueuse-functions/references/useTimeoutFn.md +51 -0
- package/skills/vueuse-functions/references/useTimeoutPoll.md +47 -0
- package/skills/vueuse-functions/references/useTimestamp.md +89 -0
- package/skills/vueuse-functions/references/useTitle.md +113 -0
- package/skills/vueuse-functions/references/useToNumber.md +54 -0
- package/skills/vueuse-functions/references/useToString.md +34 -0
- package/skills/vueuse-functions/references/useToggle.md +103 -0
- package/skills/vueuse-functions/references/useTransition.md +265 -0
- package/skills/vueuse-functions/references/useTrunc.md +33 -0
- package/skills/vueuse-functions/references/useUrlSearchParams.md +121 -0
- package/skills/vueuse-functions/references/useUserMedia.md +1138 -0
- package/skills/vueuse-functions/references/useVModel.md +182 -0
- package/skills/vueuse-functions/references/useVModels.md +67 -0
- package/skills/vueuse-functions/references/useVibrate.md +87 -0
- package/skills/vueuse-functions/references/useVirtualList.md +182 -0
- package/skills/vueuse-functions/references/useWakeLock.md +50 -0
- package/skills/vueuse-functions/references/useWebNotification.md +176 -0
- package/skills/vueuse-functions/references/useWebSocket.md +299 -0
- package/skills/vueuse-functions/references/useWebWorker.md +60 -0
- package/skills/vueuse-functions/references/useWebWorkerFn.md +102 -0
- package/skills/vueuse-functions/references/useWindowFocus.md +46 -0
- package/skills/vueuse-functions/references/useWindowScroll.md +61 -0
- package/skills/vueuse-functions/references/useWindowSize.md +76 -0
- package/skills/vueuse-functions/references/useZoomFactor.md +53 -0
- package/skills/vueuse-functions/references/useZoomLevel.md +53 -0
- package/skills/vueuse-functions/references/watchArray.md +53 -0
- package/skills/vueuse-functions/references/watchAtMost.md +55 -0
- package/skills/vueuse-functions/references/watchDebounced.md +101 -0
- package/skills/vueuse-functions/references/watchDeep.md +54 -0
- package/skills/vueuse-functions/references/watchExtractedObservable.md +192 -0
- package/skills/vueuse-functions/references/watchIgnorable.md +120 -0
- package/skills/vueuse-functions/references/watchImmediate.md +44 -0
- package/skills/vueuse-functions/references/watchOnce.md +41 -0
- package/skills/vueuse-functions/references/watchPausable.md +86 -0
- package/skills/vueuse-functions/references/watchThrottled.md +108 -0
- package/skills/vueuse-functions/references/watchTriggerable.md +98 -0
- package/skills/vueuse-functions/references/watchWithFilter.md +54 -0
- package/skills/vueuse-functions/references/whenever.md +100 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: '@Integrations'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# useSortable
|
|
6
|
+
|
|
7
|
+
Wrapper for [`sortable`](https://github.com/SortableJS/Sortable).
|
|
8
|
+
|
|
9
|
+
For more information on what options can be passed, see [`Sortable.options`](https://github.com/SortableJS/Sortable#options) in the `Sortable` documentation.
|
|
10
|
+
|
|
11
|
+
::: warning
|
|
12
|
+
Currently, `useSortable` only implements drag-and-drop sorting for a single list.
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i sortablejs@^1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Use template ref
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { useSortable } from '@vueuse/integrations/useSortable'
|
|
28
|
+
import { shallowRef, useTemplateRef } from 'vue'
|
|
29
|
+
|
|
30
|
+
const el = useTemplateRef('el')
|
|
31
|
+
const list = shallowRef([{ id: 1, name: 'a' }, { id: 2, name: 'b' }, { id: 3, name: 'c' }])
|
|
32
|
+
|
|
33
|
+
useSortable(el, list)
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<div ref="el">
|
|
38
|
+
<div v-for="item in list" :key="item.id">
|
|
39
|
+
{{ item.name }}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Use specifies the selector to operate on
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
import { useSortable } from '@vueuse/integrations/useSortable'
|
|
50
|
+
import { shallowRef, useTemplateRef } from 'vue'
|
|
51
|
+
|
|
52
|
+
const el = useTemplateRef('el')
|
|
53
|
+
const list = shallowRef([{ id: 1, name: 'a' }, { id: 2, name: 'b' }, { id: 3, name: 'c' }])
|
|
54
|
+
|
|
55
|
+
const animation = 200
|
|
56
|
+
|
|
57
|
+
const { option } = useSortable(el, list, {
|
|
58
|
+
handle: '.handle',
|
|
59
|
+
// or option set
|
|
60
|
+
// animation
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// You can use the option method to set and get the option of Sortable
|
|
64
|
+
option('animation', animation)
|
|
65
|
+
// option('animation') // 200
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<div ref="el">
|
|
70
|
+
<div v-for="item in list" :key="item.id">
|
|
71
|
+
<span>{{ item.name }}</span>
|
|
72
|
+
<span class="handle">*</span>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Use a selector to get the root element
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import { useSortable } from '@vueuse/integrations/useSortable'
|
|
83
|
+
import { shallowRef } from 'vue'
|
|
84
|
+
|
|
85
|
+
const list = shallowRef([{ id: 1, name: 'a' }, { id: 2, name: 'b' }, { id: 3, name: 'c' }])
|
|
86
|
+
|
|
87
|
+
useSortable('#dv', list)
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<div id="dv">
|
|
92
|
+
<div v-for="item in list" :key="item.id">
|
|
93
|
+
<span>{{ item.name }}</span>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Return Values
|
|
100
|
+
|
|
101
|
+
| Property | Description |
|
|
102
|
+
| -------- | ---------------------------------------------------------------- |
|
|
103
|
+
| `start` | Initialize the Sortable instance (called automatically on mount) |
|
|
104
|
+
| `stop` | Destroy the Sortable instance |
|
|
105
|
+
| `option` | Get or set Sortable options at runtime |
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const { start, stop, option } = useSortable(el, list)
|
|
109
|
+
|
|
110
|
+
// Stop sorting
|
|
111
|
+
stop()
|
|
112
|
+
|
|
113
|
+
// Start sorting again
|
|
114
|
+
start()
|
|
115
|
+
|
|
116
|
+
// Get/set options
|
|
117
|
+
option('animation', 200) // set
|
|
118
|
+
const animation = option('animation') // get
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Watch Element Changes
|
|
122
|
+
|
|
123
|
+
Use the `watchElement` option to automatically reinitialize Sortable when the element changes (useful with `v-if`).
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { useSortable } from '@vueuse/integrations/useSortable'
|
|
127
|
+
|
|
128
|
+
useSortable(el, list, {
|
|
129
|
+
watchElement: true, // auto-reinitialize when element changes
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Custom Update Handler
|
|
134
|
+
|
|
135
|
+
If you want to handle the `onUpdate` yourself, you can pass in `onUpdate` parameters, and we also exposed a function to move the item position.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { moveArrayElement, useSortable } from '@vueuse/integrations/useSortable'
|
|
139
|
+
|
|
140
|
+
useSortable(el, list, {
|
|
141
|
+
onUpdate: (e) => {
|
|
142
|
+
// do something
|
|
143
|
+
moveArrayElement(list, e.oldIndex, e.newIndex, e)
|
|
144
|
+
// nextTick required here as moveArrayElement is executed in a microtask
|
|
145
|
+
// so we need to wait until the next tick until that is finished.
|
|
146
|
+
nextTick(() => {
|
|
147
|
+
/* do something */
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Helper Functions
|
|
154
|
+
|
|
155
|
+
The following helper functions are also exported:
|
|
156
|
+
|
|
157
|
+
| Function | Description |
|
|
158
|
+
| ------------------------------------------ | ----------------------------------------------------- |
|
|
159
|
+
| `moveArrayElement(list, from, to, event?)` | Move an element in an array from one index to another |
|
|
160
|
+
| `insertNodeAt(parent, element, index)` | Insert a DOM node at a specific index |
|
|
161
|
+
| `removeNode(node)` | Remove a DOM node from its parent |
|
|
162
|
+
|
|
163
|
+
## Type Declarations
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
export interface UseSortableReturn {
|
|
167
|
+
/**
|
|
168
|
+
* start sortable instance
|
|
169
|
+
*/
|
|
170
|
+
start: () => void
|
|
171
|
+
/**
|
|
172
|
+
* destroy sortable instance
|
|
173
|
+
*/
|
|
174
|
+
stop: () => void
|
|
175
|
+
/**
|
|
176
|
+
* Options getter/setter
|
|
177
|
+
* @param name a Sortable.Options property.
|
|
178
|
+
* @param value a value.
|
|
179
|
+
*/
|
|
180
|
+
option: (<K extends keyof Sortable.Options>(
|
|
181
|
+
name: K,
|
|
182
|
+
value: Sortable.Options[K],
|
|
183
|
+
) => void)
|
|
184
|
+
& (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K])
|
|
185
|
+
}
|
|
186
|
+
export interface UseSortableOptions extends Options, ConfigurableDocument {
|
|
187
|
+
/**
|
|
188
|
+
* Watch the element reference for changes and automatically reinitialize Sortable
|
|
189
|
+
* when the element changes.
|
|
190
|
+
*
|
|
191
|
+
* When `false` (default), Sortable is only initialized once on mount.
|
|
192
|
+
* You must manually call `start()` if the element reference changes.
|
|
193
|
+
*
|
|
194
|
+
* When `true`, automatically watches the element reference and reinitializes
|
|
195
|
+
* Sortable whenever it changes (e.g., conditional rendering with v-if).
|
|
196
|
+
*
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
watchElement?: boolean
|
|
200
|
+
}
|
|
201
|
+
export declare function useSortable<T>(
|
|
202
|
+
selector: string,
|
|
203
|
+
list: MaybeRef<T[]>,
|
|
204
|
+
options?: UseSortableOptions,
|
|
205
|
+
): UseSortableReturn
|
|
206
|
+
export declare function useSortable<T>(
|
|
207
|
+
el: MaybeRefOrGetter<MaybeElement>,
|
|
208
|
+
list: MaybeRef<T[]>,
|
|
209
|
+
options?: UseSortableOptions,
|
|
210
|
+
): UseSortableReturn
|
|
211
|
+
/**
|
|
212
|
+
* Inserts a element into the DOM at a given index.
|
|
213
|
+
* @param parentElement
|
|
214
|
+
* @param element
|
|
215
|
+
* @param {number} index
|
|
216
|
+
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L81C1-L94C2
|
|
217
|
+
*/
|
|
218
|
+
export declare function insertNodeAt(
|
|
219
|
+
parentElement: Element,
|
|
220
|
+
element: Element,
|
|
221
|
+
index: number,
|
|
222
|
+
): void
|
|
223
|
+
/**
|
|
224
|
+
* Removes a node from the DOM.
|
|
225
|
+
* @param {Node} node
|
|
226
|
+
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L96C1-L102C2
|
|
227
|
+
*/
|
|
228
|
+
export declare function removeNode(node: Node): void
|
|
229
|
+
export declare function moveArrayElement<T>(
|
|
230
|
+
list: MaybeRef<T[]>,
|
|
231
|
+
from: number,
|
|
232
|
+
to: number,
|
|
233
|
+
e?: Sortable.SortableEvent | null,
|
|
234
|
+
): void
|
|
235
|
+
```
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Array
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# useSorted
|
|
6
|
+
|
|
7
|
+
reactive sort array
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { useSorted } from '@vueuse/core'
|
|
13
|
+
|
|
14
|
+
// general sort
|
|
15
|
+
const source = [10, 3, 5, 7, 2, 1, 8, 6, 9, 4]
|
|
16
|
+
const sorted = useSorted(source)
|
|
17
|
+
console.log(sorted.value) // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
18
|
+
console.log(source) // [10, 3, 5, 7, 2, 1, 8, 6, 9, 4]
|
|
19
|
+
|
|
20
|
+
// object sort
|
|
21
|
+
const objArr = [{
|
|
22
|
+
name: 'John',
|
|
23
|
+
age: 40,
|
|
24
|
+
}, {
|
|
25
|
+
name: 'Jane',
|
|
26
|
+
age: 20,
|
|
27
|
+
}, {
|
|
28
|
+
name: 'Joe',
|
|
29
|
+
age: 30,
|
|
30
|
+
}, {
|
|
31
|
+
name: 'Jenny',
|
|
32
|
+
age: 22,
|
|
33
|
+
}]
|
|
34
|
+
const objSorted = useSorted(objArr, (a, b) => a.age - b.age)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### dirty mode
|
|
38
|
+
|
|
39
|
+
dirty mode will change the source array.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const source = ref([10, 3, 5, 7, 2, 1, 8, 6, 9, 4])
|
|
43
|
+
const sorted = useSorted(source, (a, b) => a - b, {
|
|
44
|
+
dirty: true,
|
|
45
|
+
})
|
|
46
|
+
console.log(source)// output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Type Declarations
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
export type UseSortedCompareFn<T = any> = (a: T, b: T) => number
|
|
53
|
+
export type UseSortedFn<T = any> = (
|
|
54
|
+
arr: T[],
|
|
55
|
+
compareFn: UseSortedCompareFn<T>,
|
|
56
|
+
) => T[]
|
|
57
|
+
export interface UseSortedOptions<T = any> {
|
|
58
|
+
/**
|
|
59
|
+
* sort algorithm
|
|
60
|
+
*/
|
|
61
|
+
sortFn?: UseSortedFn<T>
|
|
62
|
+
/**
|
|
63
|
+
* compare function
|
|
64
|
+
*/
|
|
65
|
+
compareFn?: UseSortedCompareFn<T>
|
|
66
|
+
/**
|
|
67
|
+
* change the value of the source array
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
dirty?: boolean
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* reactive sort array
|
|
74
|
+
*
|
|
75
|
+
* @see https://vueuse.org/useSorted
|
|
76
|
+
*/
|
|
77
|
+
export declare function useSorted<T = any>(
|
|
78
|
+
source: MaybeRefOrGetter<T[]>,
|
|
79
|
+
compareFn?: UseSortedCompareFn<T>,
|
|
80
|
+
): Ref<T[]>
|
|
81
|
+
export declare function useSorted<T = any>(
|
|
82
|
+
source: MaybeRefOrGetter<T[]>,
|
|
83
|
+
options?: UseSortedOptions<T>,
|
|
84
|
+
): Ref<T[]>
|
|
85
|
+
export declare function useSorted<T = any>(
|
|
86
|
+
source: MaybeRefOrGetter<T[]>,
|
|
87
|
+
compareFn?: UseSortedCompareFn<T>,
|
|
88
|
+
options?: Omit<UseSortedOptions<T>, 'compareFn'>,
|
|
89
|
+
): Ref<T[]>
|
|
90
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Sensors
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# useSpeechRecognition
|
|
6
|
+
|
|
7
|
+
Reactive [SpeechRecognition](https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition).
|
|
8
|
+
|
|
9
|
+
> [Can I use?](https://caniuse.com/mdn-api_speechrecognitionevent)
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { useSpeechRecognition } from '@vueuse/core'
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
isSupported,
|
|
18
|
+
isListening,
|
|
19
|
+
isFinal,
|
|
20
|
+
result,
|
|
21
|
+
start,
|
|
22
|
+
stop,
|
|
23
|
+
} = useSpeechRecognition()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Options
|
|
27
|
+
|
|
28
|
+
The following shows the default values of the options, they will be directly passed to [SpeechRecognition API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition).
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { useSpeechRecognition } from '@vueuse/core'
|
|
32
|
+
// ---cut---
|
|
33
|
+
useSpeechRecognition({
|
|
34
|
+
lang: 'en-US',
|
|
35
|
+
interimResults: true,
|
|
36
|
+
continuous: true,
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Type Declarations
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
export interface UseSpeechRecognitionOptions extends ConfigurableWindow {
|
|
44
|
+
/**
|
|
45
|
+
* Controls whether continuous results are returned for each recognition, or only a single result.
|
|
46
|
+
*
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
continuous?: boolean
|
|
50
|
+
/**
|
|
51
|
+
* Controls whether interim results should be returned (true) or not (false.) Interim results are results that are not yet final
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
interimResults?: boolean
|
|
56
|
+
/**
|
|
57
|
+
* Language for SpeechRecognition
|
|
58
|
+
*
|
|
59
|
+
* @default 'en-US'
|
|
60
|
+
*/
|
|
61
|
+
lang?: MaybeRefOrGetter<string>
|
|
62
|
+
/**
|
|
63
|
+
* A number representing the maximum returned alternatives for each result.
|
|
64
|
+
*
|
|
65
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives
|
|
66
|
+
* @default 1
|
|
67
|
+
*/
|
|
68
|
+
maxAlternatives?: number
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reactive SpeechRecognition.
|
|
72
|
+
*
|
|
73
|
+
* @see https://vueuse.org/useSpeechRecognition
|
|
74
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition
|
|
75
|
+
* @param options
|
|
76
|
+
*/
|
|
77
|
+
export declare function useSpeechRecognition(
|
|
78
|
+
options?: UseSpeechRecognitionOptions,
|
|
79
|
+
): {
|
|
80
|
+
isSupported: ComputedRef<boolean>
|
|
81
|
+
isListening: ShallowRef<boolean, boolean>
|
|
82
|
+
isFinal: ShallowRef<boolean, boolean>
|
|
83
|
+
recognition: SpeechRecognition | undefined
|
|
84
|
+
result: ShallowRef<string, string>
|
|
85
|
+
error: ShallowRef<
|
|
86
|
+
Error | SpeechRecognitionErrorEvent | undefined,
|
|
87
|
+
Error | SpeechRecognitionErrorEvent | undefined
|
|
88
|
+
>
|
|
89
|
+
toggle: (value?: boolean) => void
|
|
90
|
+
start: () => void
|
|
91
|
+
stop: () => void
|
|
92
|
+
}
|
|
93
|
+
export type UseSpeechRecognitionReturn = ReturnType<typeof useSpeechRecognition>
|
|
94
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Sensors
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# useSpeechSynthesis
|
|
6
|
+
|
|
7
|
+
Reactive [SpeechSynthesis](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).
|
|
8
|
+
|
|
9
|
+
> [Can I use?](https://caniuse.com/mdn-api_speechsynthesis)
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { useSpeechSynthesis } from '@vueuse/core'
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
isSupported,
|
|
18
|
+
isPlaying,
|
|
19
|
+
status,
|
|
20
|
+
voiceInfo,
|
|
21
|
+
utterance,
|
|
22
|
+
error,
|
|
23
|
+
stop,
|
|
24
|
+
toggle,
|
|
25
|
+
speak,
|
|
26
|
+
} = useSpeechSynthesis()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Options
|
|
30
|
+
|
|
31
|
+
The following shows the default values of the options, they will be directly passed to [SpeechSynthesis API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { useSpeechSynthesis } from '@vueuse/core'
|
|
35
|
+
// ---cut---
|
|
36
|
+
useSpeechSynthesis({
|
|
37
|
+
lang: 'en-US',
|
|
38
|
+
pitch: 1,
|
|
39
|
+
rate: 1,
|
|
40
|
+
volume: 1,
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Type Declarations
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
export type UseSpeechSynthesisStatus = 'init' | 'play' | 'pause' | 'end'
|
|
48
|
+
export interface UseSpeechSynthesisOptions extends ConfigurableWindow {
|
|
49
|
+
/**
|
|
50
|
+
* Language for SpeechSynthesis
|
|
51
|
+
*
|
|
52
|
+
* @default 'en-US'
|
|
53
|
+
*/
|
|
54
|
+
lang?: MaybeRefOrGetter<string>
|
|
55
|
+
/**
|
|
56
|
+
* Gets and sets the pitch at which the utterance will be spoken at.
|
|
57
|
+
*
|
|
58
|
+
* @default 1
|
|
59
|
+
*/
|
|
60
|
+
pitch?: MaybeRefOrGetter<SpeechSynthesisUtterance['pitch']>
|
|
61
|
+
/**
|
|
62
|
+
* Gets and sets the speed at which the utterance will be spoken at.
|
|
63
|
+
*
|
|
64
|
+
* @default 1
|
|
65
|
+
*/
|
|
66
|
+
rate?: MaybeRefOrGetter<SpeechSynthesisUtterance['rate']>
|
|
67
|
+
/**
|
|
68
|
+
* Gets and sets the voice that will be used to speak the utterance.
|
|
69
|
+
*/
|
|
70
|
+
voice?: MaybeRef<SpeechSynthesisVoice>
|
|
71
|
+
/**
|
|
72
|
+
* Gets and sets the volume that the utterance will be spoken at.
|
|
73
|
+
*
|
|
74
|
+
* @default 1
|
|
75
|
+
*/
|
|
76
|
+
volume?: MaybeRefOrGetter<SpeechSynthesisUtterance['volume']>
|
|
77
|
+
/**
|
|
78
|
+
* Callback function that is called when the boundary event is triggered.
|
|
79
|
+
*/
|
|
80
|
+
onBoundary?: (event: SpeechSynthesisEvent) => void
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Reactive SpeechSynthesis.
|
|
84
|
+
*
|
|
85
|
+
* @see https://vueuse.org/useSpeechSynthesis
|
|
86
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
|
|
87
|
+
*/
|
|
88
|
+
export declare function useSpeechSynthesis(
|
|
89
|
+
text: MaybeRefOrGetter<string>,
|
|
90
|
+
options?: UseSpeechSynthesisOptions,
|
|
91
|
+
): {
|
|
92
|
+
isSupported: ComputedRef<boolean>
|
|
93
|
+
isPlaying: ShallowRef<boolean, boolean>
|
|
94
|
+
status: ShallowRef<UseSpeechSynthesisStatus, UseSpeechSynthesisStatus>
|
|
95
|
+
utterance: ComputedRef<SpeechSynthesisUtterance>
|
|
96
|
+
error: ShallowRef<
|
|
97
|
+
SpeechSynthesisErrorEvent | undefined,
|
|
98
|
+
SpeechSynthesisErrorEvent | undefined
|
|
99
|
+
>
|
|
100
|
+
stop: () => void
|
|
101
|
+
toggle: (value?: boolean) => void
|
|
102
|
+
speak: () => void
|
|
103
|
+
}
|
|
104
|
+
export type UseSpeechSynthesisReturn = ReturnType<typeof useSpeechSynthesis>
|
|
105
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: Utilities
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# useStepper
|
|
6
|
+
|
|
7
|
+
Provides helpers for building a multi-step wizard interface.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Steps as array
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { useStepper } from '@vueuse/core'
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
steps,
|
|
18
|
+
stepNames,
|
|
19
|
+
index,
|
|
20
|
+
current,
|
|
21
|
+
next,
|
|
22
|
+
previous,
|
|
23
|
+
isFirst,
|
|
24
|
+
isLast,
|
|
25
|
+
goTo,
|
|
26
|
+
goToNext,
|
|
27
|
+
goToPrevious,
|
|
28
|
+
goBackTo,
|
|
29
|
+
isNext,
|
|
30
|
+
isPrevious,
|
|
31
|
+
isCurrent,
|
|
32
|
+
isBefore,
|
|
33
|
+
isAfter,
|
|
34
|
+
} = useStepper([
|
|
35
|
+
'billing-address',
|
|
36
|
+
'terms',
|
|
37
|
+
'payment',
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
// Access the step through `current`
|
|
41
|
+
console.log(current.value) // 'billing-address'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Steps as object
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { useStepper } from '@vueuse/core'
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
steps,
|
|
51
|
+
stepNames,
|
|
52
|
+
index,
|
|
53
|
+
current,
|
|
54
|
+
next,
|
|
55
|
+
previous,
|
|
56
|
+
isFirst,
|
|
57
|
+
isLast,
|
|
58
|
+
goTo,
|
|
59
|
+
goToNext,
|
|
60
|
+
goToPrevious,
|
|
61
|
+
goBackTo,
|
|
62
|
+
isNext,
|
|
63
|
+
isPrevious,
|
|
64
|
+
isCurrent,
|
|
65
|
+
isBefore,
|
|
66
|
+
isAfter,
|
|
67
|
+
} = useStepper({
|
|
68
|
+
'user-information': {
|
|
69
|
+
title: 'User information',
|
|
70
|
+
},
|
|
71
|
+
'billing-address': {
|
|
72
|
+
title: 'Billing address',
|
|
73
|
+
},
|
|
74
|
+
'terms': {
|
|
75
|
+
title: 'Terms',
|
|
76
|
+
},
|
|
77
|
+
'payment': {
|
|
78
|
+
title: 'Payment',
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// Access the step object through `current`
|
|
83
|
+
console.log(current.value.title) // 'User information'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Type Declarations
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
export interface UseStepperReturn<StepName, Steps, Step> {
|
|
90
|
+
/** List of steps. */
|
|
91
|
+
steps: Readonly<Ref<Steps>>
|
|
92
|
+
/** List of step names. */
|
|
93
|
+
stepNames: Readonly<Ref<StepName[]>>
|
|
94
|
+
/** Index of the current step. */
|
|
95
|
+
index: Ref<number>
|
|
96
|
+
/** Current step. */
|
|
97
|
+
current: ComputedRef<Step>
|
|
98
|
+
/** Next step, or undefined if the current step is the last one. */
|
|
99
|
+
next: ComputedRef<StepName | undefined>
|
|
100
|
+
/** Previous step, or undefined if the current step is the first one. */
|
|
101
|
+
previous: ComputedRef<StepName | undefined>
|
|
102
|
+
/** Whether the current step is the first one. */
|
|
103
|
+
isFirst: ComputedRef<boolean>
|
|
104
|
+
/** Whether the current step is the last one. */
|
|
105
|
+
isLast: ComputedRef<boolean>
|
|
106
|
+
/** Get the step at the specified index. */
|
|
107
|
+
at: (index: number) => Step | undefined
|
|
108
|
+
/** Get a step by the specified name. */
|
|
109
|
+
get: (step: StepName) => Step | undefined
|
|
110
|
+
/** Go to the specified step. */
|
|
111
|
+
goTo: (step: StepName) => void
|
|
112
|
+
/** Go to the next step. Does nothing if the current step is the last one. */
|
|
113
|
+
goToNext: () => void
|
|
114
|
+
/** Go to the previous step. Does nothing if the current step is the previous one. */
|
|
115
|
+
goToPrevious: () => void
|
|
116
|
+
/** Go back to the given step, only if the current step is after. */
|
|
117
|
+
goBackTo: (step: StepName) => void
|
|
118
|
+
/** Checks whether the given step is the next step. */
|
|
119
|
+
isNext: (step: StepName) => boolean
|
|
120
|
+
/** Checks whether the given step is the previous step. */
|
|
121
|
+
isPrevious: (step: StepName) => boolean
|
|
122
|
+
/** Checks whether the given step is the current step. */
|
|
123
|
+
isCurrent: (step: StepName) => boolean
|
|
124
|
+
/** Checks if the current step is before the given step. */
|
|
125
|
+
isBefore: (step: StepName) => boolean
|
|
126
|
+
/** Checks if the current step is after the given step. */
|
|
127
|
+
isAfter: (step: StepName) => boolean
|
|
128
|
+
}
|
|
129
|
+
export declare function useStepper<T extends string | number>(
|
|
130
|
+
steps: MaybeRef<T[]>,
|
|
131
|
+
initialStep?: T,
|
|
132
|
+
): UseStepperReturn<T, T[], T>
|
|
133
|
+
export declare function useStepper<T extends Record<string, any>>(
|
|
134
|
+
steps: MaybeRef<T>,
|
|
135
|
+
initialStep?: keyof T,
|
|
136
|
+
): UseStepperReturn<Exclude<keyof T, symbol>, T, T[keyof T]>
|
|
137
|
+
```
|