@tb-dev/vue 0.1.3 → 0.1.5

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,3 +1,4 @@
1
+ import { MaybeNilRef } from '../../types/ref';
1
2
  import { Fn, MaybePromise, Option } from '@tb-dev/utils';
2
3
  import { KeyFilter, OnKeyStrokeOptions } from '@vueuse/core';
3
4
  export type KeyDownEventHandler = Option<(event: KeyboardEvent) => MaybePromise<unknown>>;
@@ -5,6 +6,7 @@ export type OnKeyDownOptions = Omit<OnKeyStrokeOptions, 'eventName'> & {
5
6
  altKey?: boolean;
6
7
  ctrlKey?: boolean;
7
8
  detached?: boolean;
9
+ enabled?: MaybeNilRef<boolean>;
8
10
  metaKey?: boolean;
9
11
  prevent?: boolean;
10
12
  shiftKey?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
2
  export * from './composables';
3
3
  export * from './utils';
4
+ export type * from './types';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, createBlock, openBlock, unref, withCtx, createElementBlock, renderSlot, toDisplayString, toRef, effectScope, computed, toValue } from 'vue';
1
+ import { defineComponent, createBlock, openBlock, unref, withCtx, createElementBlock, renderSlot, toDisplayString, toRef, effectScope, toValue, computed } from 'vue';
2
2
  import { RouterLink } from 'vue-router';
3
3
  import { computedAsync, useAsyncState, useElementSize as useElementSize$1, tryOnScopeDispose, onKeyStroke, useLocalStorage, useWindowSize } from '@vueuse/core';
4
4
  import { isNil } from '@tb-dev/utils';
@@ -85,6 +85,7 @@ function onKeyDown(key, handler, options = {}) {
85
85
  altKey = false,
86
86
  ctrlKey = false,
87
87
  detached = false,
88
+ enabled = true,
88
89
  metaKey = false,
89
90
  prevent = true,
90
91
  shiftKey = false,
@@ -100,7 +101,7 @@ function onKeyDown(key, handler, options = {}) {
100
101
  if (stopPropagation) {
101
102
  e.stopPropagation();
102
103
  }
103
- if (handler) {
104
+ if (toValue(enabled) && handler) {
104
105
  Promise.try(handler, e).catch(handleError);
105
106
  }
106
107
  };
@@ -0,0 +1,2 @@
1
+ export type * from './ref';
2
+ export type * from './symbol';
@@ -0,0 +1,3 @@
1
+ import { MaybeRefOrGetter } from 'vue';
2
+ import { Option } from '@tb-dev/utils';
3
+ export type MaybeNilRef<T> = MaybeRefOrGetter<Option<T>>;
@@ -0,0 +1,6 @@
1
+ import { ComputedRef, InjectionKey, Ref, ShallowRef } from 'vue';
2
+ export type ComputedSymbol<T> = InjectionKey<ComputedRef<T>>;
3
+ export type RefSymbol<T> = InjectionKey<Readonly<Ref<T>>>;
4
+ export type ShallowRefSymbol<T> = InjectionKey<Readonly<ShallowRef<T>>>;
5
+ export type WritableRefSymbol<T> = InjectionKey<Ref<T>>;
6
+ export type WritableShallowRefSymbol<T> = InjectionKey<ShallowRef<T>>;
@@ -0,0 +1,6 @@
1
+ import { App, InjectionKey } from 'vue';
2
+ export declare const getCurrentApp: () => App<any>, setCurrentApp: (app: App) => void;
3
+ export declare function runWithContext<T>(fn: () => T): T;
4
+ export declare function provide<T>(key: InjectionKey<T>, value: T): void;
5
+ export declare function inject<T>(key: InjectionKey<T>): T;
6
+ export declare function fallibleInject<T>(key: InjectionKey<T>): T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,22 +25,22 @@
25
25
  "composables"
26
26
  ],
27
27
  "dependencies": {
28
- "@tb-dev/utils": "^5.1.4",
28
+ "@tb-dev/utils": "^6.0.0",
29
29
  "@vueuse/core": "^13.0.0",
30
30
  "lucide-vue-next": "^0.484.0",
31
31
  "vue": "^3.5.13",
32
32
  "vue-router": "^4.5.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@tailwindcss/vite": "^4.0.15",
36
- "@tb-dev/eslint-config": "^6.7.1",
35
+ "@tailwindcss/vite": "^4.0.17",
36
+ "@tb-dev/eslint-config": "^6.7.2",
37
37
  "@types/node": "^22.13.14",
38
38
  "@vitejs/plugin-vue": "^5.2.3",
39
39
  "eslint": "^9.23.0",
40
40
  "prettier": "^3.5.3",
41
41
  "prettier-plugin-css-order": "^2.1.2",
42
42
  "prettier-plugin-tailwindcss": "^0.6.11",
43
- "tailwindcss": "^4.0.15",
43
+ "tailwindcss": "^4.0.17",
44
44
  "tslib": "^2.8.1",
45
45
  "typescript": "~5.8.2",
46
46
  "vite": "^6.2.3",