@v-c/util 1.2.1 → 1.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.
@@ -22,10 +22,12 @@ function measureScrollbarSize(ele) {
22
22
  const width = parseInt(webkitScrollbarStyle.width, 10);
23
23
  const height = parseInt(webkitScrollbarStyle.height, 10);
24
24
  try {
25
+ const widthStyle = width ? `width: ${webkitScrollbarStyle.width};` : "";
26
+ const heightStyle = height ? `height: ${webkitScrollbarStyle.height};` : "";
25
27
  updateCSS(`
26
28
  #${randomId}::-webkit-scrollbar {
27
- ${width ? `width: ${webkitScrollbarStyle.width};` : ""}
28
- ${height ? `height: ${webkitScrollbarStyle.height};` : ""}
29
+ ${widthStyle}
30
+ ${heightStyle}
29
31
  }`, randomId);
30
32
  } catch (e) {
31
33
  console.error(e);
@@ -6,7 +6,8 @@ import { onBeforeUnmount, ref } from "vue";
6
6
  * Pending updates are always replaced by the latest one.
7
7
  */
8
8
  function useDelayState(defaultValue) {
9
- const value = ref(typeof defaultValue === "function" ? defaultValue() : defaultValue);
9
+ const initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
10
+ const value = ref(initValue);
10
11
  let delayInfo = null;
11
12
  const cancelPending = () => {
12
13
  if (delayInfo) {
@@ -2,10 +2,11 @@ import { isReactive, isRef, ref, watch } from "vue";
2
2
  //#region src/hooks/useMemo.ts
3
3
  function useMemo(getValue, condition, shouldUpdate) {
4
4
  const cacheRef = ref(getValue());
5
- watch(condition.map((item) => {
5
+ const sources = condition.map((item) => {
6
6
  if (typeof item === "function" || isRef(item) || isReactive(item)) return item;
7
7
  return () => item;
8
- }), (next, pre) => {
8
+ });
9
+ watch(sources, (next, pre) => {
9
10
  if (shouldUpdate) {
10
11
  if (shouldUpdate(next, pre)) cacheRef.value = getValue();
11
12
  } else cacheRef.value = getValue();
@@ -1,7 +1,8 @@
1
1
  import { ref } from "vue";
2
2
  //#region src/hooks/useState.ts
3
3
  function useState(defaultStateValue) {
4
- const innerValue = ref(typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue);
4
+ const initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
5
+ const innerValue = ref(initValue);
5
6
  function triggerChange(newValue) {
6
7
  innerValue.value = newValue;
7
8
  }
@@ -22,9 +22,10 @@ function flattenChildren(children, isFilterEmpty = true) {
22
22
  temp.forEach((child) => {
23
23
  if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
24
24
  else if (isValid(child)) res.push(child);
25
- else if (child && typeof child === "object" && child.type === Fragment) if (child.key === skipFlattenKey) res.push(child);
26
- else res.push(...flattenChildren(child.children, isFilterEmpty));
27
- else if (child && isVNode(child)) {
25
+ else if (child && typeof child === "object" && child.type === Fragment) {
26
+ if (child.key === skipFlattenKey) res.push(child);
27
+ else res.push(...flattenChildren(child.children, isFilterEmpty));
28
+ } else if (child && isVNode(child)) {
28
29
  if (isFilterEmpty && !isEmptyElement(child)) res.push(child);
29
30
  else if (!isFilterEmpty) res.push(child);
30
31
  }
package/dist/type.d.ts CHANGED
@@ -59,4 +59,15 @@ export declare function someType<T>(types?: any[], defaultVal?: T): {
59
59
  };
60
60
  export type CustomSlotsType<T extends Record<string, any>> = SlotsType<T>;
61
61
  export type AnyObject = Record<PropertyKey, any>;
62
+ /**
63
+ * Identity wrapper understood by `vite-plugin-tsx-resolve-types`: the wrapped
64
+ * type is excluded from runtime prop inference, the way `/* @vue-ignore *\/`
65
+ * is, but the marker survives declaration emit so it also works for types
66
+ * consumed from a published `.d.ts`.
67
+ *
68
+ * `interface Props extends Base, VueIgnore<Emits> {}` keeps the `Emits`
69
+ * members as fallthrough attrs; `x?: VueIgnore<Heavy>` declares `x` with no
70
+ * runtime type check.
71
+ */
72
+ export type VueIgnore<T> = T;
62
73
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/util",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "description": "Vue3 components utils",
6
6
  "author": {
7
7
  "name": "aibayanyu20",