@tb-dev/vue 0.2.1 → 0.3.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.
@@ -1,10 +1,12 @@
1
- import { ShallowRef } from 'vue';
2
1
  import { UseAsyncStateOptions } from '@vueuse/core';
3
2
  type Options = Omit<UseAsyncStateOptions<true>, 'shallow'>;
4
3
  export interface AsyncRefOptions extends Options {
5
4
  immediate?: boolean;
6
5
  }
7
- export declare function asyncRef<T>(initial: T, fn: () => Promise<T>, options?: AsyncRefOptions): Readonly<ShallowRef<T>> & {
6
+ export declare function asyncRef<T>(initial: T, fn: () => Promise<T>, options?: AsyncRefOptions): {
7
+ state: import('vue').Ref<T, T>;
8
8
  execute: (delay?: number, ...args: any[]) => Promise<T>;
9
+ isLoading: import('vue').Ref<boolean, boolean>;
10
+ isReady: import('vue').Ref<boolean, boolean>;
9
11
  };
10
12
  export {};
@@ -6,4 +6,6 @@ export declare function useElementSize<T extends MaybeElement>(element: MaybeRef
6
6
  stop: () => void;
7
7
  };
8
8
  export declare function useHeight<T extends MaybeElement>(element: MaybeRefOrGetter<T>): Readonly<Ref<number>>;
9
+ export declare function useHeightDiff<T extends MaybeElement>(element: MaybeRefOrGetter<T>): import('vue').ComputedRef<number>;
9
10
  export declare function useWidth<T extends MaybeElement>(element: MaybeRefOrGetter<T>): Readonly<Ref<number>>;
11
+ export declare function useWidthDiff<T extends MaybeElement>(element: MaybeRefOrGetter<T>): import('vue').ComputedRef<number>;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { unwrap, isNil, toPixel } from '@tb-dev/utils';
6
6
  import { Primitive, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaRoot, ScrollAreaViewport, ScrollAreaCorner, useForwardPropsEmits, CheckboxRoot, CheckboxIndicator, ContextMenuRoot, ContextMenuCheckboxItem, ContextMenuItemIndicator, ContextMenuPortal, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, useForwardProps, ContextMenuSubTrigger, ContextMenuTrigger, DialogRoot, DialogClose, DialogOverlay, DialogPortal, DialogContent, DialogDescription, DialogTitle, DialogTrigger, DropdownMenuRoot, DropdownMenuCheckboxItem, DropdownMenuItemIndicator, DropdownMenuPortal, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, NumberFieldRoot, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, Label, PopoverRoot, PopoverAnchor, PopoverPortal, PopoverContent, PopoverTrigger, ProgressRoot, ProgressIndicator, RadioGroupRoot, RadioGroupItem, RadioGroupIndicator, SelectRoot, SelectPortal, SelectContent, SelectViewport, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectIcon, SelectValue, Separator, createContext, TooltipRoot, TooltipPortal, TooltipContent, TooltipArrow, TooltipProvider, TooltipTrigger, TabsRoot, TabsContent, TabsList, TabsTrigger, TagsInputRoot, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, Toggle } from 'reka-ui';
7
7
  export { DropdownMenuPortal } from 'reka-ui';
8
8
  import { RouterLink } from 'vue-router';
9
- import { createReusableTemplate, reactiveOmit, useVModel, useMediaQuery, useEventListener, computedAsync, useAsyncState, useElementSize as useElementSize$1, tryOnScopeDispose, onKeyStroke, useLocalStorage, useWindowSize } from '@vueuse/core';
9
+ import { createReusableTemplate, reactiveOmit, useVModel, useMediaQuery, useEventListener, computedAsync, useAsyncState, useWindowSize, useElementSize as useElementSize$1, tryOnScopeDispose, onKeyStroke, useLocalStorage } from '@vueuse/core';
10
10
  import { Check, Circle, ChevronRight, X, Minus, Plus, CircleIcon, ChevronDown, ChevronUp } from 'lucide-vue-next';
11
11
 
12
12
  function create$1() {
@@ -3885,7 +3885,7 @@ function asyncComputed(initial, callback, options) {
3885
3885
 
3886
3886
  function asyncRef(initial, fn, options = {}) {
3887
3887
  const { immediate = true } = options;
3888
- const { execute, state } = useAsyncState(fn, initial, {
3888
+ const { execute, state, isLoading, isReady } = useAsyncState(fn, initial, {
3889
3889
  immediate,
3890
3890
  onError: handleError,
3891
3891
  resetOnExecute: false,
@@ -3893,7 +3893,19 @@ function asyncRef(initial, fn, options = {}) {
3893
3893
  throwError: false,
3894
3894
  ...options
3895
3895
  });
3896
- return Object.assign(state, { execute });
3896
+ return {
3897
+ state,
3898
+ execute,
3899
+ isLoading,
3900
+ isReady
3901
+ };
3902
+ }
3903
+
3904
+ function useWindowHeight() {
3905
+ return useWindowSize().height;
3906
+ }
3907
+ function useWindowWidth() {
3908
+ return useWindowSize().width;
3897
3909
  }
3898
3910
 
3899
3911
  function useElementSize(element) {
@@ -3902,9 +3914,19 @@ function useElementSize(element) {
3902
3914
  function useHeight(element) {
3903
3915
  return useElementSize(element).height;
3904
3916
  }
3917
+ function useHeightDiff(element) {
3918
+ const height = useHeight(element);
3919
+ const windowHeight = useWindowHeight();
3920
+ return computed(() => windowHeight.value - height.value);
3921
+ }
3905
3922
  function useWidth(element) {
3906
3923
  return useElementSize(element).width;
3907
3924
  }
3925
+ function useWidthDiff(element) {
3926
+ const width = useWidth(element);
3927
+ const windowWidth = useWindowWidth();
3928
+ return computed(() => windowWidth.value - width.value);
3929
+ }
3908
3930
 
3909
3931
  function onKeyDown(key, handler, options = {}) {
3910
3932
  const {
@@ -3984,11 +4006,4 @@ function localRef(key, initial, options) {
3984
4006
  });
3985
4007
  }
3986
4008
 
3987
- function useWindowHeight() {
3988
- return useWindowSize().height;
3989
- }
3990
- function useWindowWidth() {
3991
- return useWindowSize().width;
3992
- }
3993
-
3994
- export { _sfc_main$1T as Badge, _sfc_main$1S as Button, _sfc_main$1R as ButtonLink, _sfc_main$1J as Card, _sfc_main$1I as Checkbox, _sfc_main$1H as ContextMenu, _sfc_main$1G as ContextMenuCheckboxItem, _sfc_main$1F as ContextMenuContent, _sfc_main$1E as ContextMenuGroup, _sfc_main$1D as ContextMenuItem, _sfc_main$1C as ContextMenuLabel, _sfc_main$1B as ContextMenuRadioGroup, _sfc_main$1A as ContextMenuRadioItem, _sfc_main$1z as ContextMenuSeparator, _sfc_main$1y as ContextMenuShortcut, _sfc_main$1x as ContextMenuSub, _sfc_main$1w as ContextMenuSubContent, _sfc_main$1v as ContextMenuSubTrigger, _sfc_main$1u as ContextMenuTrigger, _sfc_main$1t as Dialog, _sfc_main$1s as DialogClose, _sfc_main$1q as DialogContent, _sfc_main$1p as DialogDescription, _sfc_main$1o as DialogFooter, _sfc_main$1n as DialogHeader, _sfc_main$1r as DialogOverlay, _sfc_main$1m as DialogScrollContent, _sfc_main$1l as DialogTitle, _sfc_main$1k as DialogTrigger, _sfc_main$1j as DropdownMenu, _sfc_main$1i as DropdownMenuCheckboxItem, _sfc_main$1h as DropdownMenuContent, _sfc_main$1g as DropdownMenuGroup, _sfc_main$1f as DropdownMenuItem, _sfc_main$1e as DropdownMenuLabel, _sfc_main$1d as DropdownMenuRadioGroup, _sfc_main$1c as DropdownMenuRadioItem, _sfc_main$1b as DropdownMenuSeparator, _sfc_main$1a as DropdownMenuShortcut, _sfc_main$19 as DropdownMenuSub, _sfc_main$18 as DropdownMenuSubContent, _sfc_main$17 as DropdownMenuSubTrigger, _sfc_main$16 as DropdownMenuTrigger, _sfc_main$15 as Input, _sfc_main$$ as InputNumber, _sfc_main$_ as InputText, _sfc_main$Y as Label, _sfc_main$X as Link, _sfc_main$W as Popover, _sfc_main$V as PopoverAnchor, _sfc_main$U as PopoverContent, _sfc_main$T as PopoverTrigger, _sfc_main$S as Progress, _sfc_main$R as RadioGroup, _sfc_main$Q as RadioGroupItem, _sfc_main$1P as ScrollArea, _sfc_main$P as Select, _sfc_main$O as SelectContent, _sfc_main$N as SelectGroup, _sfc_main$M as SelectItem, _sfc_main$L as SelectItemText, _sfc_main$K as SelectLabel, _sfc_main$J as SelectScrollDownButton, _sfc_main$I as SelectScrollUpButton, _sfc_main$H as SelectSeparator, _sfc_main$G as SelectTrigger, _sfc_main$F as SelectValue, _sfc_main$E as Separator, _sfc_main$D as Sheet, _sfc_main$C as SheetClose, _sfc_main$A as SheetContent, _sfc_main$z as SheetDescription, _sfc_main$y as SheetFooter, _sfc_main$x as SheetHeader, _sfc_main$w as SheetTitle, _sfc_main$v as SheetTrigger, _sfc_main$j as Sidebar, _sfc_main$l as Skeleton, _sfc_main$c as Table, _sfc_main$g as TableCell, _sfc_main$e as TableHead, _sfc_main$b as TableLink, _sfc_main$f as TableRow, _sfc_main$a as Tabs, _sfc_main$9 as TabsContent, _sfc_main$8 as TabsList, _sfc_main$7 as TabsTrigger, _sfc_main$6 as TagsInput, _sfc_main$5 as TagsInputInput, _sfc_main$4 as TagsInputItem, _sfc_main$3 as TagsInputItemDelete, _sfc_main$2 as TagsInputItemText, _sfc_main$1 as Textarea, _sfc_main as Toggle, _sfc_main$p as Tooltip, _sfc_main$o as TooltipContent, _sfc_main$n as TooltipProvider, _sfc_main$m as TooltipTrigger, asyncComputed, asyncRef, cn, getCurrentApp, getErrorHandler, handleError, inject, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, provide, runWithContext, setCurrentApp, setErrorHandler, tryGetCurrentApp, tryInject, trySetCurrentApp, useElementSize, useHeight, useSidebar, useWidth, useWindowHeight, useWindowWidth };
4009
+ export { _sfc_main$1T as Badge, _sfc_main$1S as Button, _sfc_main$1R as ButtonLink, _sfc_main$1J as Card, _sfc_main$1I as Checkbox, _sfc_main$1H as ContextMenu, _sfc_main$1G as ContextMenuCheckboxItem, _sfc_main$1F as ContextMenuContent, _sfc_main$1E as ContextMenuGroup, _sfc_main$1D as ContextMenuItem, _sfc_main$1C as ContextMenuLabel, _sfc_main$1B as ContextMenuRadioGroup, _sfc_main$1A as ContextMenuRadioItem, _sfc_main$1z as ContextMenuSeparator, _sfc_main$1y as ContextMenuShortcut, _sfc_main$1x as ContextMenuSub, _sfc_main$1w as ContextMenuSubContent, _sfc_main$1v as ContextMenuSubTrigger, _sfc_main$1u as ContextMenuTrigger, _sfc_main$1t as Dialog, _sfc_main$1s as DialogClose, _sfc_main$1q as DialogContent, _sfc_main$1p as DialogDescription, _sfc_main$1o as DialogFooter, _sfc_main$1n as DialogHeader, _sfc_main$1r as DialogOverlay, _sfc_main$1m as DialogScrollContent, _sfc_main$1l as DialogTitle, _sfc_main$1k as DialogTrigger, _sfc_main$1j as DropdownMenu, _sfc_main$1i as DropdownMenuCheckboxItem, _sfc_main$1h as DropdownMenuContent, _sfc_main$1g as DropdownMenuGroup, _sfc_main$1f as DropdownMenuItem, _sfc_main$1e as DropdownMenuLabel, _sfc_main$1d as DropdownMenuRadioGroup, _sfc_main$1c as DropdownMenuRadioItem, _sfc_main$1b as DropdownMenuSeparator, _sfc_main$1a as DropdownMenuShortcut, _sfc_main$19 as DropdownMenuSub, _sfc_main$18 as DropdownMenuSubContent, _sfc_main$17 as DropdownMenuSubTrigger, _sfc_main$16 as DropdownMenuTrigger, _sfc_main$15 as Input, _sfc_main$$ as InputNumber, _sfc_main$_ as InputText, _sfc_main$Y as Label, _sfc_main$X as Link, _sfc_main$W as Popover, _sfc_main$V as PopoverAnchor, _sfc_main$U as PopoverContent, _sfc_main$T as PopoverTrigger, _sfc_main$S as Progress, _sfc_main$R as RadioGroup, _sfc_main$Q as RadioGroupItem, _sfc_main$1P as ScrollArea, _sfc_main$P as Select, _sfc_main$O as SelectContent, _sfc_main$N as SelectGroup, _sfc_main$M as SelectItem, _sfc_main$L as SelectItemText, _sfc_main$K as SelectLabel, _sfc_main$J as SelectScrollDownButton, _sfc_main$I as SelectScrollUpButton, _sfc_main$H as SelectSeparator, _sfc_main$G as SelectTrigger, _sfc_main$F as SelectValue, _sfc_main$E as Separator, _sfc_main$D as Sheet, _sfc_main$C as SheetClose, _sfc_main$A as SheetContent, _sfc_main$z as SheetDescription, _sfc_main$y as SheetFooter, _sfc_main$x as SheetHeader, _sfc_main$w as SheetTitle, _sfc_main$v as SheetTrigger, _sfc_main$j as Sidebar, _sfc_main$l as Skeleton, _sfc_main$c as Table, _sfc_main$g as TableCell, _sfc_main$e as TableHead, _sfc_main$b as TableLink, _sfc_main$f as TableRow, _sfc_main$a as Tabs, _sfc_main$9 as TabsContent, _sfc_main$8 as TabsList, _sfc_main$7 as TabsTrigger, _sfc_main$6 as TagsInput, _sfc_main$5 as TagsInputInput, _sfc_main$4 as TagsInputItem, _sfc_main$3 as TagsInputItemDelete, _sfc_main$2 as TagsInputItemText, _sfc_main$1 as Textarea, _sfc_main as Toggle, _sfc_main$p as Tooltip, _sfc_main$o as TooltipContent, _sfc_main$n as TooltipProvider, _sfc_main$m as TooltipTrigger, asyncComputed, asyncRef, cn, getCurrentApp, getErrorHandler, handleError, inject, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, provide, runWithContext, setCurrentApp, setErrorHandler, tryGetCurrentApp, tryInject, trySetCurrentApp, useElementSize, useHeight, useHeightDiff, useSidebar, useWidth, useWidthDiff, useWindowHeight, useWindowWidth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",