@pequity/squirrel 5.0.1 → 5.0.2

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.
@@ -19,7 +19,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
19
19
  },
20
20
  __name: "p-loading",
21
21
  setup(__props) {
22
- const { show, content, props: componentProps } = usePLoading.usePLoading();
22
+ const { show, content, props: componentProps, loadingHide } = usePLoading.usePLoading();
23
23
  const dimsReference = vue.ref(null);
24
24
  const width = vue.ref(0);
25
25
  const height = vue.ref(0);
@@ -37,6 +37,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
37
37
  const isComponent2 = typeof content2 === "object" && content2 !== null;
38
38
  return isComponent2;
39
39
  };
40
+ vue.onBeforeUnmount(() => {
41
+ loadingHide();
42
+ });
40
43
  return (_ctx, _cache) => {
41
44
  return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
42
45
  vue.createVNode(vue.Transition, {
@@ -82,5 +85,5 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
82
85
  };
83
86
  }
84
87
  });
85
- const pLoading = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-7af44c7f"]]);
88
+ const pLoading = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-f0f6bdd4"]]);
86
89
  module.exports = pLoading;
@@ -12,11 +12,17 @@ const props = vue.computed(() => {
12
12
  var _a;
13
13
  return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.props;
14
14
  });
15
- let timer;
16
15
  const usePLoading = (options) => {
17
16
  const { delay } = { delay: 200, ...options };
18
17
  const scope = vue.getCurrentScope();
18
+ const clearLoadingItems = () => {
19
+ loadingItems.value.forEach((item) => {
20
+ clearTimeout(item.timer);
21
+ });
22
+ loadingItems.value = [];
23
+ };
19
24
  const loadingShow = (loadingItem) => {
25
+ let timer = 0;
20
26
  if (!loadingItem.id) {
21
27
  throw new Error("id is required");
22
28
  }
@@ -30,28 +36,39 @@ const usePLoading = (options) => {
30
36
  loadingItems.value.push({
31
37
  id: loadingItem.id,
32
38
  content: loadingItem.content && typeof loadingItem.content === "object" ? vue.markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT,
33
- props: loadingItem.props
39
+ props: loadingItem.props,
40
+ timer,
41
+ clearOnDispose: loadingItem.clearOnDispose ?? true
34
42
  });
35
43
  };
36
44
  const loadingHide = (id) => {
37
45
  if (id && typeof id === "string") {
38
46
  const index = loadingItems.value.findIndex((item) => item.id === id);
47
+ const loadingItem = loadingItems.value[index];
39
48
  if (index !== -1) {
49
+ clearTimeout(loadingItem.timer);
40
50
  loadingItems.value.splice(index, 1);
41
51
  }
42
52
  } else {
43
- loadingItems.value = [];
53
+ clearLoadingItems();
44
54
  }
45
55
  if (loadingItems.value.length === 0) {
46
56
  show.value = false;
47
57
  }
48
- clearTimeout(timer);
49
58
  };
50
59
  if (scope) {
51
60
  vue.onScopeDispose(() => {
52
- loadingItems.value = [];
53
- show.value = false;
54
- clearTimeout(timer);
61
+ if (loadingItems.value.some((item) => item.clearOnDispose === false)) {
62
+ loadingItems.value.forEach((item) => {
63
+ if (item.clearOnDispose) {
64
+ clearTimeout(item.timer);
65
+ }
66
+ });
67
+ loadingItems.value = loadingItems.value.filter((item) => item.clearOnDispose === false);
68
+ } else {
69
+ clearLoadingItems();
70
+ show.value = false;
71
+ }
55
72
  });
56
73
  }
57
74
  return { show, content, props, loadingShow, loadingHide };
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, toValue, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, unref, createElementBlock, createElementVNode, normalizeStyle, resolveDynamicComponent, normalizeProps, mergeProps, normalizeClass, toDisplayString, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, watch, toValue, onBeforeUnmount, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, unref, createElementBlock, createElementVNode, normalizeStyle, resolveDynamicComponent, normalizeProps, mergeProps, normalizeClass, toDisplayString, createCommentVNode } from "vue";
2
2
  import { usePLoading } from "./usePLoading.js";
3
3
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
4
4
  const _hoisted_1 = {
@@ -18,7 +18,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18
18
  },
19
19
  __name: "p-loading",
20
20
  setup(__props) {
21
- const { show, content, props: componentProps } = usePLoading();
21
+ const { show, content, props: componentProps, loadingHide } = usePLoading();
22
22
  const dimsReference = ref(null);
23
23
  const width = ref(0);
24
24
  const height = ref(0);
@@ -36,6 +36,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
36
  const isComponent2 = typeof content2 === "object" && content2 !== null;
37
37
  return isComponent2;
38
38
  };
39
+ onBeforeUnmount(() => {
40
+ loadingHide();
41
+ });
39
42
  return (_ctx, _cache) => {
40
43
  return openBlock(), createBlock(Teleport, { to: "body" }, [
41
44
  createVNode(Transition, {
@@ -81,7 +84,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
81
84
  };
82
85
  }
83
86
  });
84
- const pLoading = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7af44c7f"]]);
87
+ const pLoading = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f0f6bdd4"]]);
85
88
  export {
86
89
  pLoading as default
87
90
  };
@@ -10,11 +10,17 @@ const props = computed(() => {
10
10
  var _a;
11
11
  return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.props;
12
12
  });
13
- let timer;
14
13
  const usePLoading = (options) => {
15
14
  const { delay } = { delay: 200, ...options };
16
15
  const scope = getCurrentScope();
16
+ const clearLoadingItems = () => {
17
+ loadingItems.value.forEach((item) => {
18
+ clearTimeout(item.timer);
19
+ });
20
+ loadingItems.value = [];
21
+ };
17
22
  const loadingShow = (loadingItem) => {
23
+ let timer = 0;
18
24
  if (!loadingItem.id) {
19
25
  throw new Error("id is required");
20
26
  }
@@ -28,28 +34,39 @@ const usePLoading = (options) => {
28
34
  loadingItems.value.push({
29
35
  id: loadingItem.id,
30
36
  content: loadingItem.content && typeof loadingItem.content === "object" ? markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT,
31
- props: loadingItem.props
37
+ props: loadingItem.props,
38
+ timer,
39
+ clearOnDispose: loadingItem.clearOnDispose ?? true
32
40
  });
33
41
  };
34
42
  const loadingHide = (id) => {
35
43
  if (id && typeof id === "string") {
36
44
  const index = loadingItems.value.findIndex((item) => item.id === id);
45
+ const loadingItem = loadingItems.value[index];
37
46
  if (index !== -1) {
47
+ clearTimeout(loadingItem.timer);
38
48
  loadingItems.value.splice(index, 1);
39
49
  }
40
50
  } else {
41
- loadingItems.value = [];
51
+ clearLoadingItems();
42
52
  }
43
53
  if (loadingItems.value.length === 0) {
44
54
  show.value = false;
45
55
  }
46
- clearTimeout(timer);
47
56
  };
48
57
  if (scope) {
49
58
  onScopeDispose(() => {
50
- loadingItems.value = [];
51
- show.value = false;
52
- clearTimeout(timer);
59
+ if (loadingItems.value.some((item) => item.clearOnDispose === false)) {
60
+ loadingItems.value.forEach((item) => {
61
+ if (item.clearOnDispose) {
62
+ clearTimeout(item.timer);
63
+ }
64
+ });
65
+ loadingItems.value = loadingItems.value.filter((item) => item.clearOnDispose === false);
66
+ } else {
67
+ clearLoadingItems();
68
+ show.value = false;
69
+ }
53
70
  });
54
71
  }
55
72
  return { show, content, props, loadingShow, loadingHide };
@@ -1,17 +1,14 @@
1
- declare var __VLS_0: {
2
- titleClass: "text-xl font-medium leading-none text-p-purple-60";
3
- };
4
- declare var __VLS_1: {};
5
- declare var __VLS_inheritedAttrs: {};
6
- declare const __VLS_templateResult: {
1
+ declare function __VLS_template(): {
7
2
  slots: {
8
- title?(_: typeof __VLS_0): any;
9
- default?(_: typeof __VLS_1): any;
3
+ title?(_: {
4
+ titleClass: "text-xl font-medium leading-none text-p-purple-60";
5
+ }): any;
6
+ default?(_: {}): any;
10
7
  };
11
8
  refs: {};
12
- attrs: Partial<typeof __VLS_inheritedAttrs>;
9
+ attrs: Partial<{}>;
13
10
  };
14
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
11
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
12
  declare const __VLS_component: import("vue").DefineComponent<{
16
13
  title: {
17
14
  type: StringConstructor;
@@ -25,7 +22,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
25
22
  }>>, {
26
23
  title: string;
27
24
  }, {}>;
28
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
25
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
29
26
  export default _default;
30
27
  type __VLS_WithTemplateSlots<T, S> = T & {
31
28
  new (): {
@@ -1,15 +1,12 @@
1
- declare var __VLS_0: {};
2
- declare var __VLS_1: {};
3
- declare var __VLS_inheritedAttrs: {};
4
- declare const __VLS_templateResult: {
1
+ declare function __VLS_template(): {
5
2
  slots: {
6
- "label-before"?(_: typeof __VLS_0): any;
7
- label?(_: typeof __VLS_1): any;
3
+ "label-before"?(_: {}): any;
4
+ label?(_: {}): any;
8
5
  };
9
6
  refs: {};
10
- attrs: Partial<typeof __VLS_inheritedAttrs>;
7
+ attrs: Partial<{}>;
11
8
  };
12
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
9
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
10
  declare const __VLS_component: import("vue").DefineComponent<{
14
11
  modelValue: {
15
12
  type: BooleanConstructor;
@@ -36,7 +33,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
36
33
  label: string;
37
34
  modelValue: boolean;
38
35
  }, {}>;
39
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
36
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
40
37
  export default _default;
41
38
  type __VLS_WithTemplateSlots<T, S> = T & {
42
39
  new (): {
@@ -2,8 +2,7 @@ import { type PropType } from 'vue';
2
2
  import { type ModelValue, type Size } from '../p-select-list/p-select-list.types';
3
3
  type AnyValue = string | number | boolean | null | undefined | Record<string, unknown>;
4
4
  type AnyObject = Record<string, AnyValue>;
5
- declare var __VLS_inheritedAttrs: {};
6
- declare const __VLS_templateResult: {
5
+ declare function __VLS_template(): {
7
6
  slots: Readonly<{
8
7
  'selected-item'(props: {
9
8
  item: any;
@@ -26,9 +25,9 @@ declare const __VLS_templateResult: {
26
25
  }): unknown;
27
26
  };
28
27
  refs: {
29
- formControl: import("vue").HTMLAttributes & import("vue").ReservedProps;
30
- button: import("vue").ButtonHTMLAttributes & import("vue").ReservedProps;
31
- actionsContainer: import("vue").HTMLAttributes & import("vue").ReservedProps;
28
+ formControl: HTMLDivElement;
29
+ button: HTMLButtonElement;
30
+ actionsContainer: HTMLDivElement;
32
31
  inputSearch: import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
33
32
  modelValue: {
34
33
  type: StringConstructor;
@@ -116,11 +115,11 @@ declare const __VLS_templateResult: {
116
115
  modelValue: string;
117
116
  showEnterIcon: boolean;
118
117
  }> | null;
119
- virtualizerRef: import("vue").HTMLAttributes & import("vue").ReservedProps;
118
+ virtualizerRef: HTMLDivElement;
120
119
  };
121
- attrs: Partial<typeof __VLS_inheritedAttrs>;
120
+ attrs: Partial<{}>;
122
121
  };
123
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
122
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
124
123
  declare const __VLS_component: import("vue").DefineComponent<{
125
124
  modelValue: {
126
125
  type: PropType<ModelValue>;
@@ -381,7 +380,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
381
380
  placeholderSearch: string;
382
381
  selectedTopShown: boolean;
383
382
  }, {}>;
384
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
383
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
385
384
  export default _default;
386
385
  type __VLS_WithTemplateSlots<T, S> = T & {
387
386
  new (): {
@@ -1,12 +1,11 @@
1
- declare var __VLS_inheritedAttrs: {};
2
- declare const __VLS_templateResult: {
1
+ declare function __VLS_template(): {
3
2
  slots: {
4
3
  default?(_: {}): any;
5
4
  };
6
5
  refs: {};
7
- attrs: Partial<typeof __VLS_inheritedAttrs>;
6
+ attrs: Partial<{}>;
8
7
  };
9
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
8
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
9
  declare const __VLS_component: import("vue").DefineComponent<{
11
10
  text: {
12
11
  type: StringConstructor;
@@ -20,7 +19,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
20
19
  }>>, {
21
20
  text: string;
22
21
  }, {}>;
23
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
22
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
24
23
  export default _default;
25
24
  type __VLS_WithTemplateSlots<T, S> = T & {
26
25
  new (): {
@@ -1,16 +1,15 @@
1
1
  import { type RouterLinkProps } from 'vue-router';
2
- declare var __VLS_inheritedAttrs: {};
3
- declare const __VLS_templateResult: {
2
+ declare function __VLS_template(): {
4
3
  slots: {
5
4
  default?(_: {}): any;
6
5
  default?(_: {}): any;
7
6
  };
8
7
  refs: {};
9
- attrs: Partial<typeof __VLS_inheritedAttrs>;
8
+ attrs: Partial<{}>;
10
9
  };
11
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
12
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<RouterLinkProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<RouterLinkProps>>>, {}, {}>;
13
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
12
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
14
13
  export default _default;
15
14
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
16
15
  type __VLS_TypePropsToOption<T> = {
@@ -7,13 +7,16 @@ type LoadingItem = {
7
7
  id: string;
8
8
  content?: Content;
9
9
  props?: Ref;
10
+ timer: ReturnType<typeof setTimeout> | 0;
11
+ clearOnDispose?: boolean;
10
12
  };
13
+ type LoadingItemOption = Pick<LoadingItem, 'id' | 'content' | 'props' | 'clearOnDispose'>;
11
14
  type UsePLoading = {
12
15
  show: Ref<boolean>;
13
16
  content: Content;
14
17
  props: Ref;
15
- loadingShow: (loadingItem: LoadingItem) => void;
16
- loadingHide: (id: LoadingItem['id']) => void;
18
+ loadingShow: (loadingItem: LoadingItemOption) => void;
19
+ loadingHide: (id?: LoadingItemOption['id']) => void;
17
20
  };
18
21
  export declare const usePLoading: (options?: Options) => UsePLoading;
19
22
  export {};
@@ -1,6 +1,5 @@
1
1
  import { type PropType, type StyleValue } from 'vue';
2
- declare var __VLS_inheritedAttrs: {};
3
- declare const __VLS_templateResult: {
2
+ declare function __VLS_template(): {
4
3
  slots: {
5
4
  "title-wrapper"?(_: {}): any;
6
5
  "content-wrapper"?(_: {}): any;
@@ -9,12 +8,12 @@ declare const __VLS_templateResult: {
9
8
  footer?(_: {}): any;
10
9
  };
11
10
  refs: {
12
- pmWrapper: import("vue").HTMLAttributes & import("vue").ReservedProps;
13
- pm: import("vue").HTMLAttributes & import("vue").ReservedProps;
11
+ pmWrapper: HTMLDivElement;
12
+ pm: HTMLDivElement;
14
13
  };
15
- attrs: Partial<typeof __VLS_inheritedAttrs>;
14
+ attrs: Partial<{}>;
16
15
  };
17
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
16
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
18
17
  declare const __VLS_component: import("vue").DefineComponent<{
19
18
  name: {
20
19
  type: StringConstructor;
@@ -206,7 +205,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
206
205
  bgInClass: string;
207
206
  bgOutClass: string;
208
207
  }, {}>;
209
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
208
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
210
209
  export default _default;
211
210
  type __VLS_WithTemplateSlots<T, S> = T & {
212
211
  new (): {
@@ -1,12 +1,11 @@
1
- declare var __VLS_inheritedAttrs: {};
2
- declare const __VLS_templateResult: {
1
+ declare function __VLS_template(): {
3
2
  slots: {
4
3
  "no-results"?(_: {}): any;
5
4
  };
6
5
  refs: {};
7
- attrs: Partial<typeof __VLS_inheritedAttrs>;
6
+ attrs: Partial<{}>;
8
7
  };
9
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
8
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
9
  declare const __VLS_component: import("vue").DefineComponent<{
11
10
  /**
12
11
  * The current page.
@@ -71,7 +70,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
71
70
  pageSize: number;
72
71
  currentPage: number;
73
72
  }, {}>;
74
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
73
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
75
74
  export default _default;
76
75
  type __VLS_WithTemplateSlots<T, S> = T & {
77
76
  new (): {
@@ -1,18 +1,16 @@
1
1
  import { type InputSize } from '../../utils/inputClassesShared';
2
2
  import { type PropType } from 'vue';
3
- declare var __VLS_0: {
4
- label: string;
5
- labelClasses: string;
6
- };
7
- declare var __VLS_inheritedAttrs: {};
8
- declare const __VLS_templateResult: {
3
+ declare function __VLS_template(): {
9
4
  slots: {
10
- label?(_: typeof __VLS_0): any;
5
+ label?(_: {
6
+ label: string;
7
+ labelClasses: string;
8
+ }): any;
11
9
  };
12
10
  refs: {};
13
- attrs: Partial<typeof __VLS_inheritedAttrs>;
11
+ attrs: Partial<{}>;
14
12
  };
15
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
16
14
  declare const __VLS_component: import("vue").DefineComponent<{
17
15
  modelValue: {
18
16
  type: PropType<string | number | boolean | null>;
@@ -95,7 +93,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
95
93
  errorMsg: string;
96
94
  itemValue: string | number | boolean | null;
97
95
  }, {}>;
98
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
96
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
99
97
  export default _default;
100
98
  type __VLS_WithTemplateSlots<T, S> = T & {
101
99
  new (): {
@@ -13,16 +13,15 @@ type Props = {
13
13
  multiple?: boolean;
14
14
  noPadding?: boolean;
15
15
  };
16
- declare var __VLS_inheritedAttrs: {};
17
- declare const __VLS_templateResult: {
16
+ declare function __VLS_template(): {
18
17
  slots: Partial<Record<`btn-${number}`, (_: {
19
18
  item: BtnGroupItem;
20
19
  isSelected: boolean | undefined;
21
20
  }) => any>>;
22
21
  refs: {};
23
- attrs: Partial<typeof __VLS_inheritedAttrs>;
22
+ attrs: Partial<{}>;
24
23
  };
25
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
24
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
26
25
  declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
27
26
  modelValue: null;
28
27
  items: () => never[];
@@ -64,7 +63,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<
64
63
  highlightSelected: boolean;
65
64
  noPadding: boolean;
66
65
  }, {}>;
67
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
66
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
68
67
  export default _default;
69
68
  type __VLS_WithDefaults<P, D> = {
70
69
  [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
@@ -1,7 +1,6 @@
1
1
  import { type AnyObject, type AnyValue, type ModelValue, type Size } from './p-select-list.types';
2
2
  import { type PropType } from 'vue';
3
- declare var __VLS_inheritedAttrs: {};
4
- declare const __VLS_templateResult: {
3
+ declare function __VLS_template(): {
5
4
  slots: Readonly<{
6
5
  'selected-item'(props: {
7
6
  item: any;
@@ -24,8 +23,8 @@ declare const __VLS_templateResult: {
24
23
  }): unknown;
25
24
  };
26
25
  refs: {
27
- formControl: import("vue").HTMLAttributes & import("vue").ReservedProps;
28
- actionsContainer: import("vue").HTMLAttributes & import("vue").ReservedProps;
26
+ formControl: HTMLDivElement;
27
+ actionsContainer: HTMLDivElement;
29
28
  inputSearch: import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
30
29
  modelValue: {
31
30
  type: StringConstructor;
@@ -113,11 +112,11 @@ declare const __VLS_templateResult: {
113
112
  modelValue: string;
114
113
  showEnterIcon: boolean;
115
114
  }> | null;
116
- virtualizerRef: import("vue").HTMLAttributes & import("vue").ReservedProps;
115
+ virtualizerRef: HTMLDivElement;
117
116
  };
118
- attrs: Partial<typeof __VLS_inheritedAttrs>;
117
+ attrs: Partial<{}>;
119
118
  };
120
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
119
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
121
120
  declare const __VLS_component: import("vue").DefineComponent<{
122
121
  modelValue: {
123
122
  type: PropType<ModelValue>;
@@ -360,7 +359,7 @@ declare const __VLS_component: import("vue").DefineComponent<{
360
359
  topSectionClass: string;
361
360
  closePopperOnSelect: boolean;
362
361
  }, {}>;
363
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
362
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
364
363
  export default _default;
365
364
  type __VLS_WithTemplateSlots<T, S> = T & {
366
365
  new (): {
@@ -11,20 +11,18 @@ type Props = {
11
11
  paddingBottom: number;
12
12
  };
13
13
  };
14
- declare var __VLS_11: {};
15
- declare var __VLS_inheritedAttrs: {};
16
- declare const __VLS_templateResult: {
14
+ declare function __VLS_template(): {
17
15
  slots: Partial<Record<`prepend-header-cell-${string}`, (_: {
18
16
  col: TableCol;
19
17
  }) => any>> & Partial<Record<`subheader-cell-${string}`, (_: {}) => any>> & {
20
- default?(_: typeof __VLS_11): any;
18
+ default?(_: {}): any;
21
19
  };
22
20
  refs: {
23
- scrollWrapper: import("vue").HTMLAttributes & import("vue").ReservedProps;
21
+ scrollWrapper: HTMLDivElement;
24
22
  };
25
- attrs: Partial<typeof __VLS_inheritedAttrs>;
23
+ attrs: Partial<{}>;
26
24
  };
27
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
25
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
28
26
  declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
29
27
  colsResizable: boolean;
30
28
  isFirstColFixed: boolean;
@@ -64,7 +62,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<
64
62
  paddingBottom: number;
65
63
  };
66
64
  }, {}>;
67
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
65
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
68
66
  export default _default;
69
67
  type __VLS_WithDefaults<P, D> = {
70
68
  [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
@@ -3,16 +3,14 @@ type Props = {
3
3
  isEditable?: boolean;
4
4
  isSelected?: boolean;
5
5
  };
6
- declare var __VLS_0: {};
7
- declare var __VLS_inheritedAttrs: {};
8
- declare const __VLS_templateResult: {
6
+ declare function __VLS_template(): {
9
7
  slots: {
10
- default?(_: typeof __VLS_0): any;
8
+ default?(_: {}): any;
11
9
  };
12
10
  refs: {};
13
- attrs: Partial<typeof __VLS_inheritedAttrs>;
11
+ attrs: Partial<{}>;
14
12
  };
15
- type __VLS_Slots = typeof __VLS_templateResult['slots'];
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
16
14
  declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
17
15
  isEditable: boolean;
18
16
  isSelected: boolean;
@@ -23,7 +21,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<
23
21
  isSelected: boolean;
24
22
  isEditable: boolean;
25
23
  }, {}>;
26
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_Slots>;
24
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
27
25
  export default _default;
28
26
  type __VLS_WithDefaults<P, D> = {
29
27
  [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
package/dist/style.css CHANGED
@@ -381,12 +381,12 @@ from {
381
381
  to {
382
382
  opacity: 0;
383
383
  }
384
- }.fadeInDown[data-v-7af44c7f] {
384
+ }.fadeInDown[data-v-f0f6bdd4] {
385
385
  animation-duration: 0.4s;
386
386
  animation-fill-mode: both;
387
- animation-name: fadeInDown-7af44c7f;
387
+ animation-name: fadeInDown-f0f6bdd4;
388
388
  }
389
- @keyframes fadeInDown-7af44c7f {
389
+ @keyframes fadeInDown-f0f6bdd4 {
390
390
  0% {
391
391
  opacity: 0;
392
392
  transform: translate3d(0, -100%, 0);
@@ -396,12 +396,12 @@ to {
396
396
  transform: none;
397
397
  }
398
398
  }
399
- .fadeOutUp[data-v-7af44c7f] {
399
+ .fadeOutUp[data-v-f0f6bdd4] {
400
400
  animation-duration: 0.25s;
401
401
  animation-fill-mode: both;
402
- animation-name: fadeOutUp-7af44c7f;
402
+ animation-name: fadeOutUp-f0f6bdd4;
403
403
  }
404
- @keyframes fadeOutUp-7af44c7f {
404
+ @keyframes fadeOutUp-f0f6bdd4 {
405
405
  0% {
406
406
  opacity: 1;
407
407
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "5.0.1",
4
+ "version": "5.0.2",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -55,7 +55,7 @@
55
55
  "@commitlint/cli": "^19.4.1",
56
56
  "@commitlint/config-conventional": "^19.4.1",
57
57
  "@pequity/eslint-config": "^0.0.13",
58
- "@playwright/test": "^1.46.1",
58
+ "@playwright/test": "^1.47.0",
59
59
  "@popperjs/core": "2.11.8",
60
60
  "@semantic-release/changelog": "^6.0.3",
61
61
  "@semantic-release/git": "^10.0.1",
@@ -75,20 +75,18 @@
75
75
  "@types/jest": "^29.5.12",
76
76
  "@types/jsdom": "^21.1.7",
77
77
  "@types/lodash-es": "^4.17.12",
78
- "@types/node": "^22.5.3",
78
+ "@types/node": "^22.5.4",
79
79
  "@vitejs/plugin-vue": "^5.1.3",
80
80
  "@vue/compiler-sfc": "3.4.38",
81
81
  "@vue/test-utils": "^2.4.6",
82
82
  "@vue/vue3-jest": "^29.2.6",
83
83
  "autoprefixer": "^10.4.20",
84
84
  "babel-jest": "^29.7.0",
85
- "concurrently": "^8.2.2",
86
85
  "dayjs": "1.11.13",
87
86
  "eslint": "^8.57.0",
88
87
  "eslint-plugin-storybook": "^0.8.0",
89
88
  "floating-vue": "5.2.2",
90
89
  "glob": "^11.0.0",
91
- "http-server": "^14.1.1",
92
90
  "husky": "^9.1.5",
93
91
  "jest": "^29.7.0",
94
92
  "jest-environment-jsdom": "^29.7.0",
@@ -113,6 +111,6 @@
113
111
  "vue-currency-input": "3.1.0",
114
112
  "vue-router": "4.4.3",
115
113
  "vue-toastification": "2.0.0-rc.5",
116
- "vue-tsc": "2.1.4"
114
+ "vue-tsc": "2.1.6"
117
115
  }
118
116
  }
@@ -24,7 +24,7 @@ const createWrapper = (options) => {
24
24
  <button class="request-1-sec-component" @click="fireRequestComponent(1000)"></button>
25
25
  `,
26
26
  setup() {
27
- const { loadingShow, loadingHide } = usePLoading(options);
27
+ const { loadingShow, loadingHide, show } = usePLoading(options);
28
28
 
29
29
  const fireRequest = async (time) => {
30
30
  const id = `default-${time}`;
@@ -47,7 +47,7 @@ const createWrapper = (options) => {
47
47
  loadingHide(id);
48
48
  };
49
49
 
50
- return { loadingShow, loadingHide, fireRequest, fireRequestText, fireRequestComponent };
50
+ return { loadingShow, loadingHide, fireRequest, fireRequestText, fireRequestComponent, show };
51
51
  },
52
52
  },
53
53
  {
@@ -287,4 +287,22 @@ describe('PLoading.vue', () => {
287
287
  await waitNT(appWrapper.vm);
288
288
  expect(appWrapper.find('[aria-busy]').exists()).toBe(false);
289
289
  });
290
+
291
+ it('hides the loader on unmount', async () => {
292
+ const wrapper = createWrapper({ delay: 200 });
293
+
294
+ await wrapper.find('.request-1-sec-component').trigger('click');
295
+
296
+ jest.advanceTimersByTime(300);
297
+ await waitNT(appWrapper.vm);
298
+
299
+ expect(wrapper.vm.show).toBe(true);
300
+ expect(appWrapper.find('[aria-busy]').exists()).toBe(true);
301
+ expect(appWrapper.findComponent(PSkeletonLoader).exists()).toBe(true);
302
+
303
+ appWrapper.unmount();
304
+
305
+ expect(wrapper.vm.show).toBe(false);
306
+ expect(appWrapper.exists()).toBe(false);
307
+ });
290
308
  });
@@ -28,7 +28,7 @@
28
28
  </template>
29
29
 
30
30
  <script setup lang="ts">
31
- import { type Component, ref, toValue, watch } from 'vue';
31
+ import { type Component, onBeforeUnmount, ref, toValue, watch } from 'vue';
32
32
  import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
33
33
 
34
34
  const textDivClass = `overflow-hidden whitespace-nowrap px-4 pt-1 h-8 text-center text-sm font-semibold text-p-purple-60`;
@@ -37,7 +37,7 @@ defineOptions({
37
37
  name: 'PLoading',
38
38
  });
39
39
 
40
- const { show, content, props: componentProps } = usePLoading();
40
+ const { show, content, props: componentProps, loadingHide } = usePLoading();
41
41
  const dimsReference = ref<HTMLElement | null>(null);
42
42
  const width = ref(0);
43
43
  const height = ref(0);
@@ -58,6 +58,10 @@ const isComponent = (content: unknown): content is Component => {
58
58
 
59
59
  return isComponent;
60
60
  };
61
+
62
+ onBeforeUnmount(() => {
63
+ loadingHide();
64
+ });
61
65
  </script>
62
66
 
63
67
  <style scoped lang="scss">
@@ -10,14 +10,18 @@ type LoadingItem = {
10
10
  id: string;
11
11
  content?: Content;
12
12
  props?: Ref;
13
+ timer: ReturnType<typeof setTimeout> | 0;
14
+ clearOnDispose?: boolean;
13
15
  };
14
16
 
17
+ type LoadingItemOption = Pick<LoadingItem, 'id' | 'content' | 'props' | 'clearOnDispose'>;
18
+
15
19
  type UsePLoading = {
16
20
  show: Ref<boolean>;
17
21
  content: Content;
18
22
  props: Ref;
19
- loadingShow: (loadingItem: LoadingItem) => void;
20
- loadingHide: (id: LoadingItem['id']) => void;
23
+ loadingShow: (loadingItem: LoadingItemOption) => void;
24
+ loadingHide: (id?: LoadingItemOption['id']) => void;
21
25
  };
22
26
 
23
27
  const LOADING_TEXT = 'Loading...';
@@ -25,13 +29,21 @@ const show = ref(false);
25
29
  const loadingItems = ref<LoadingItem[]>([]);
26
30
  const content = computed(() => loadingItems.value[loadingItems.value.length - 1]?.content);
27
31
  const props = computed(() => loadingItems.value[loadingItems.value.length - 1]?.props);
28
- let timer: ReturnType<typeof setTimeout>;
29
32
 
30
33
  export const usePLoading = (options?: Options): UsePLoading => {
31
34
  const { delay } = { delay: 200, ...options };
32
35
  const scope = getCurrentScope();
33
36
 
34
- const loadingShow = (loadingItem: LoadingItem) => {
37
+ const clearLoadingItems = () => {
38
+ loadingItems.value.forEach((item) => {
39
+ clearTimeout(item.timer);
40
+ });
41
+ loadingItems.value = [];
42
+ };
43
+
44
+ const loadingShow = (loadingItem: LoadingItemOption) => {
45
+ let timer: ReturnType<typeof setTimeout> | 0 = 0;
46
+
35
47
  if (!loadingItem.id) {
36
48
  throw new Error('id is required');
37
49
  }
@@ -51,31 +63,42 @@ export const usePLoading = (options?: Options): UsePLoading => {
51
63
  ? markRaw(loadingItem.content)
52
64
  : loadingItem.content || LOADING_TEXT,
53
65
  props: loadingItem.props,
66
+ timer,
67
+ clearOnDispose: loadingItem.clearOnDispose ?? true,
54
68
  });
55
69
  };
56
70
 
57
- const loadingHide = (id?: LoadingItem['id']) => {
71
+ const loadingHide = (id?: LoadingItemOption['id']) => {
58
72
  if (id && typeof id === 'string') {
59
73
  const index = loadingItems.value.findIndex((item) => item.id === id);
74
+ const loadingItem = loadingItems.value[index];
60
75
 
61
76
  if (index !== -1) {
77
+ clearTimeout(loadingItem.timer);
62
78
  loadingItems.value.splice(index, 1);
63
79
  }
64
80
  } else {
65
- loadingItems.value = [];
81
+ clearLoadingItems();
66
82
  }
67
83
 
68
84
  if (loadingItems.value.length === 0) {
69
85
  show.value = false;
70
86
  }
71
- clearTimeout(timer);
72
87
  };
73
88
 
74
89
  if (scope) {
75
90
  onScopeDispose(() => {
76
- loadingItems.value = [];
77
- show.value = false;
78
- clearTimeout(timer);
91
+ if (loadingItems.value.some((item) => item.clearOnDispose === false)) {
92
+ loadingItems.value.forEach((item) => {
93
+ if (item.clearOnDispose) {
94
+ clearTimeout(item.timer);
95
+ }
96
+ });
97
+ loadingItems.value = loadingItems.value.filter((item) => item.clearOnDispose === false);
98
+ } else {
99
+ clearLoadingItems();
100
+ show.value = false;
101
+ }
79
102
  });
80
103
  }
81
104