@pequity/squirrel 3.0.2 → 3.1.1

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.
Files changed (27) hide show
  1. package/dist/cjs/index.js +3 -3
  2. package/dist/cjs/p-loading.js +28 -16
  3. package/dist/cjs/usePLoading.js +15 -3
  4. package/dist/es/index.js +3 -3
  5. package/dist/es/p-loading.js +29 -17
  6. package/dist/es/usePLoading.js +15 -3
  7. package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +2 -2
  8. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +1 -1
  9. package/dist/squirrel/components/p-loading/usePLoading.d.ts +2 -0
  10. package/dist/squirrel/components/p-select-list/useSelectList.d.ts +4 -4
  11. package/dist/squirrel/components/p-table/usePTableColResize.d.ts +4 -4
  12. package/dist/squirrel/components/p-table/usePTableRowVirtualizer.d.ts +10 -4
  13. package/dist/squirrel/composables/useInputClasses.d.ts +1 -1
  14. package/dist/style.css +6 -6
  15. package/package.json +31 -32
  16. package/squirrel/components/p-action-bar/p-action-bar.spec.js +2 -2
  17. package/squirrel/components/p-action-bar/p-action-bar.stories.js +73 -26
  18. package/squirrel/components/p-action-bar/p-action-bar.vue +5 -5
  19. package/squirrel/components/p-alert/p-alert.stories.js +1 -2
  20. package/squirrel/components/p-btn/p-btn.stories.js +1 -2
  21. package/squirrel/components/p-close-btn/p-close-btn.stories.js +1 -2
  22. package/squirrel/components/p-loading/p-loading.spec.js +58 -0
  23. package/squirrel/components/p-loading/p-loading.stories.js +57 -2
  24. package/squirrel/components/p-loading/p-loading.vue +17 -11
  25. package/squirrel/components/p-loading/usePLoading.ts +15 -2
  26. package/squirrel/components/p-select-btn/p-select-btn.stories.js +1 -2
  27. package/squirrel/components/p-select-pill/p-select-pill.stories.js +1 -2
package/dist/cjs/index.js CHANGED
@@ -60,10 +60,10 @@ const dom = require("./dom.js");
60
60
  const object = require("./object.js");
61
61
  const listKeyboardNavigation = require("./listKeyboardNavigation.js");
62
62
  const number = require("./number.js");
63
- const _hoisted_1$4 = { class: "flex h-12 min-w-fit select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white" };
63
+ const _hoisted_1$4 = { class: "flex h-12 w-max select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white" };
64
64
  const _hoisted_2$4 = { class: "whitespace-nowrap px-3" };
65
65
  const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "mx-4 h-9 w-0.5 shrink-0 rounded bg-p-purple-50" }, null, -1);
66
- const _hoisted_4$4 = { class: "flex min-w-fit" };
66
+ const _hoisted_4$4 = { class: "flex" };
67
67
  const _hoisted_5$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
68
68
  const _hoisted_6$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
69
69
  const _hoisted_7$3 = { class: "flex flex-col bg-p-purple-60" };
@@ -83,7 +83,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
83
83
  return (_ctx, _cache) => {
84
84
  return vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
85
85
  vue.createElementVNode("div", vue.mergeProps({
86
- class: "fixed bottom-6 z-[100] flex w-full justify-center",
86
+ class: "fixed bottom-6 left-1/2 z-[100] -translate-x-2/4",
87
87
  role: "alertdialog"
88
88
  }, _ctx.$attrs), [
89
89
  vue.createElementVNode("div", _hoisted_1$4, [
@@ -12,20 +12,23 @@ const _hoisted_2 = {
12
12
  key: 0,
13
13
  class: "invisible fixed"
14
14
  };
15
+ const textDivClass = `overflow-hidden whitespace-nowrap px-4 pt-1 h-8 text-center text-sm font-semibold text-p-purple-60`;
15
16
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
16
17
  ...{
17
18
  name: "PLoading"
18
19
  },
19
20
  __name: "p-loading",
20
21
  setup(__props) {
21
- const { show, content } = usePLoading.usePLoading();
22
- const widthReference = vue.ref(null);
22
+ const { show, content, props: componentProps } = usePLoading.usePLoading();
23
+ const dimsReference = vue.ref(null);
23
24
  const width = vue.ref(0);
25
+ const height = vue.ref(0);
24
26
  vue.watch(
25
27
  () => vue.toValue(content),
26
28
  () => {
27
- if (widthReference.value) {
28
- width.value = widthReference.value.offsetWidth;
29
+ if (dimsReference.value) {
30
+ width.value = dimsReference.value.offsetWidth;
31
+ height.value = dimsReference.value.offsetHeight;
29
32
  }
30
33
  },
31
34
  { flush: "post" }
@@ -44,12 +47,21 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
44
47
  default: vue.withCtx(() => [
45
48
  vue.unref(show) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
46
49
  vue.createElementVNode("div", {
47
- style: vue.normalizeStyle({ width: `${width.value}px` }),
48
- class: "h-8 overflow-hidden whitespace-nowrap rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 px-4 pt-2 text-center text-sm font-semibold leading-none text-p-purple-60 shadow-sm transition-all duration-500"
50
+ style: vue.normalizeStyle({ width: `${width.value}px`, height: `${height.value}px` }),
51
+ class: "overflow-hidden rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 shadow-sm transition-all duration-300"
49
52
  }, [
50
- isComponent(vue.unref(content)) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(content)), { key: 0 })) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
51
- vue.createTextVNode(vue.toDisplayString(vue.unref(content)), 1)
52
- ], 64))
53
+ vue.createVNode(vue.Transition, {
54
+ "enter-from-class": "opacity-0",
55
+ "enter-active-class": "transition duration-500"
56
+ }, {
57
+ default: vue.withCtx(() => [
58
+ isComponent(vue.unref(content)) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(content)), vue.normalizeProps(vue.mergeProps({ key: 0 }, vue.unref(componentProps))), null, 16)) : (vue.openBlock(), vue.createElementBlock("div", {
59
+ key: 1,
60
+ class: vue.normalizeClass(textDivClass)
61
+ }, vue.toDisplayString(vue.unref(content)), 1))
62
+ ]),
63
+ _: 1
64
+ })
53
65
  ], 4)
54
66
  ])) : vue.createCommentVNode("", true)
55
67
  ]),
@@ -57,18 +69,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
57
69
  }),
58
70
  vue.unref(content) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
59
71
  vue.createElementVNode("div", {
60
- ref_key: "widthReference",
61
- ref: widthReference,
62
- class: "inline-flex px-4"
72
+ ref_key: "dimsReference",
73
+ ref: dimsReference
63
74
  }, [
64
- isComponent(vue.unref(content)) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(content)), { key: 0 })) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
65
- vue.createTextVNode(vue.toDisplayString(vue.unref(content)), 1)
66
- ], 64))
75
+ isComponent(vue.unref(content)) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(content)), vue.normalizeProps(vue.mergeProps({ key: 0 }, vue.unref(componentProps))), null, 16)) : (vue.openBlock(), vue.createElementBlock("div", {
76
+ key: 1,
77
+ class: vue.normalizeClass(textDivClass)
78
+ }, vue.toDisplayString(vue.unref(content)), 1))
67
79
  ], 512)
68
80
  ])) : vue.createCommentVNode("", true)
69
81
  ], 64);
70
82
  };
71
83
  }
72
84
  });
73
- const pLoading = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-8c0c66ab"]]);
85
+ const pLoading = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-6f528d56"]]);
74
86
  module.exports = pLoading;
@@ -8,6 +8,10 @@ const content = vue.computed(() => {
8
8
  var _a;
9
9
  return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.content;
10
10
  });
11
+ const props = vue.computed(() => {
12
+ var _a;
13
+ return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.props;
14
+ });
11
15
  let timer;
12
16
  const usePLoading = (options) => {
13
17
  const { delay } = { delay: 200, ...options };
@@ -25,11 +29,19 @@ const usePLoading = (options) => {
25
29
  }
26
30
  loadingItems.value.push({
27
31
  id: loadingItem.id,
28
- content: loadingItem.content && typeof loadingItem.content === "object" ? vue.markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT
32
+ content: loadingItem.content && typeof loadingItem.content === "object" ? vue.markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT,
33
+ props: loadingItem.props
29
34
  });
30
35
  };
31
36
  const loadingHide = (id) => {
32
- loadingItems.value = id && typeof id === "string" ? loadingItems.value.filter((item) => item.id !== id) : [];
37
+ if (id && typeof id === "string") {
38
+ const index = loadingItems.value.findIndex((item) => item.id === id);
39
+ if (index !== -1) {
40
+ loadingItems.value.splice(index, 1);
41
+ }
42
+ } else {
43
+ loadingItems.value = [];
44
+ }
33
45
  if (loadingItems.value.length === 0) {
34
46
  show.value = false;
35
47
  }
@@ -42,6 +54,6 @@ const usePLoading = (options) => {
42
54
  clearTimeout(timer);
43
55
  });
44
56
  }
45
- return { show, content, loadingShow, loadingHide };
57
+ return { show, content, props, loadingShow, loadingHide };
46
58
  };
47
59
  exports.usePLoading = usePLoading;
package/dist/es/index.js CHANGED
@@ -60,10 +60,10 @@ import { getNextActiveElement, isElement, isVisible } from "./dom.js";
60
60
  import { isObject } from "./object.js";
61
61
  import { setupListKeyboardNavigation } from "./listKeyboardNavigation.js";
62
62
  import { toNumberOrNull } from "./number.js";
63
- const _hoisted_1$4 = { class: "flex h-12 min-w-fit select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white" };
63
+ const _hoisted_1$4 = { class: "flex h-12 w-max select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white" };
64
64
  const _hoisted_2$4 = { class: "whitespace-nowrap px-3" };
65
65
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("div", { class: "mx-4 h-9 w-0.5 shrink-0 rounded bg-p-purple-50" }, null, -1);
66
- const _hoisted_4$4 = { class: "flex min-w-fit" };
66
+ const _hoisted_4$4 = { class: "flex" };
67
67
  const _hoisted_5$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
68
68
  const _hoisted_6$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
69
69
  const _hoisted_7$3 = { class: "flex flex-col bg-p-purple-60" };
@@ -83,7 +83,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
83
83
  return (_ctx, _cache) => {
84
84
  return openBlock(), createBlock(Teleport, { to: "body" }, [
85
85
  createElementVNode("div", mergeProps({
86
- class: "fixed bottom-6 z-[100] flex w-full justify-center",
86
+ class: "fixed bottom-6 left-1/2 z-[100] -translate-x-2/4",
87
87
  role: "alertdialog"
88
88
  }, _ctx.$attrs), [
89
89
  createElementVNode("div", _hoisted_1$4, [
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, toValue, openBlock, createElementBlock, Fragment, createVNode, Transition, withCtx, unref, createElementVNode, normalizeStyle, createBlock, resolveDynamicComponent, createTextVNode, toDisplayString, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, watch, toValue, openBlock, createElementBlock, Fragment, createVNode, Transition, withCtx, unref, createElementVNode, normalizeStyle, createBlock, 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 = {
@@ -11,20 +11,23 @@ const _hoisted_2 = {
11
11
  key: 0,
12
12
  class: "invisible fixed"
13
13
  };
14
+ const textDivClass = `overflow-hidden whitespace-nowrap px-4 pt-1 h-8 text-center text-sm font-semibold text-p-purple-60`;
14
15
  const _sfc_main = /* @__PURE__ */ defineComponent({
15
16
  ...{
16
17
  name: "PLoading"
17
18
  },
18
19
  __name: "p-loading",
19
20
  setup(__props) {
20
- const { show, content } = usePLoading();
21
- const widthReference = ref(null);
21
+ const { show, content, props: componentProps } = usePLoading();
22
+ const dimsReference = ref(null);
22
23
  const width = ref(0);
24
+ const height = ref(0);
23
25
  watch(
24
26
  () => toValue(content),
25
27
  () => {
26
- if (widthReference.value) {
27
- width.value = widthReference.value.offsetWidth;
28
+ if (dimsReference.value) {
29
+ width.value = dimsReference.value.offsetWidth;
30
+ height.value = dimsReference.value.offsetHeight;
28
31
  }
29
32
  },
30
33
  { flush: "post" }
@@ -43,12 +46,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
43
46
  default: withCtx(() => [
44
47
  unref(show) ? (openBlock(), createElementBlock("div", _hoisted_1, [
45
48
  createElementVNode("div", {
46
- style: normalizeStyle({ width: `${width.value}px` }),
47
- class: "h-8 overflow-hidden whitespace-nowrap rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 px-4 pt-2 text-center text-sm font-semibold leading-none text-p-purple-60 shadow-sm transition-all duration-500"
49
+ style: normalizeStyle({ width: `${width.value}px`, height: `${height.value}px` }),
50
+ class: "overflow-hidden rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 shadow-sm transition-all duration-300"
48
51
  }, [
49
- isComponent(unref(content)) ? (openBlock(), createBlock(resolveDynamicComponent(unref(content)), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
50
- createTextVNode(toDisplayString(unref(content)), 1)
51
- ], 64))
52
+ createVNode(Transition, {
53
+ "enter-from-class": "opacity-0",
54
+ "enter-active-class": "transition duration-500"
55
+ }, {
56
+ default: withCtx(() => [
57
+ isComponent(unref(content)) ? (openBlock(), createBlock(resolveDynamicComponent(unref(content)), normalizeProps(mergeProps({ key: 0 }, unref(componentProps))), null, 16)) : (openBlock(), createElementBlock("div", {
58
+ key: 1,
59
+ class: normalizeClass(textDivClass)
60
+ }, toDisplayString(unref(content)), 1))
61
+ ]),
62
+ _: 1
63
+ })
52
64
  ], 4)
53
65
  ])) : createCommentVNode("", true)
54
66
  ]),
@@ -56,20 +68,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
68
  }),
57
69
  unref(content) ? (openBlock(), createElementBlock("div", _hoisted_2, [
58
70
  createElementVNode("div", {
59
- ref_key: "widthReference",
60
- ref: widthReference,
61
- class: "inline-flex px-4"
71
+ ref_key: "dimsReference",
72
+ ref: dimsReference
62
73
  }, [
63
- isComponent(unref(content)) ? (openBlock(), createBlock(resolveDynamicComponent(unref(content)), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
64
- createTextVNode(toDisplayString(unref(content)), 1)
65
- ], 64))
74
+ isComponent(unref(content)) ? (openBlock(), createBlock(resolveDynamicComponent(unref(content)), normalizeProps(mergeProps({ key: 0 }, unref(componentProps))), null, 16)) : (openBlock(), createElementBlock("div", {
75
+ key: 1,
76
+ class: normalizeClass(textDivClass)
77
+ }, toDisplayString(unref(content)), 1))
66
78
  ], 512)
67
79
  ])) : createCommentVNode("", true)
68
80
  ], 64);
69
81
  };
70
82
  }
71
83
  });
72
- const pLoading = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8c0c66ab"]]);
84
+ const pLoading = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6f528d56"]]);
73
85
  export {
74
86
  pLoading as default
75
87
  };
@@ -6,6 +6,10 @@ const content = computed(() => {
6
6
  var _a;
7
7
  return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.content;
8
8
  });
9
+ const props = computed(() => {
10
+ var _a;
11
+ return (_a = loadingItems.value[loadingItems.value.length - 1]) == null ? void 0 : _a.props;
12
+ });
9
13
  let timer;
10
14
  const usePLoading = (options) => {
11
15
  const { delay } = { delay: 200, ...options };
@@ -23,11 +27,19 @@ const usePLoading = (options) => {
23
27
  }
24
28
  loadingItems.value.push({
25
29
  id: loadingItem.id,
26
- content: loadingItem.content && typeof loadingItem.content === "object" ? markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT
30
+ content: loadingItem.content && typeof loadingItem.content === "object" ? markRaw(loadingItem.content) : loadingItem.content || LOADING_TEXT,
31
+ props: loadingItem.props
27
32
  });
28
33
  };
29
34
  const loadingHide = (id) => {
30
- loadingItems.value = id && typeof id === "string" ? loadingItems.value.filter((item) => item.id !== id) : [];
35
+ if (id && typeof id === "string") {
36
+ const index = loadingItems.value.findIndex((item) => item.id === id);
37
+ if (index !== -1) {
38
+ loadingItems.value.splice(index, 1);
39
+ }
40
+ } else {
41
+ loadingItems.value = [];
42
+ }
31
43
  if (loadingItems.value.length === 0) {
32
44
  show.value = false;
33
45
  }
@@ -40,7 +52,7 @@ const usePLoading = (options) => {
40
52
  clearTimeout(timer);
41
53
  });
42
54
  }
43
- return { show, content, loadingShow, loadingHide };
55
+ return { show, content, props, loadingShow, loadingHide };
44
56
  };
45
57
  export {
46
58
  usePLoading
@@ -5,10 +5,10 @@ type Props = {
5
5
  };
6
6
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
7
  "click:dismiss": () => void;
8
- "click:action": (value: string | undefined) => void;
8
+ "click:action": (args_0: string | undefined) => void;
9
9
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<Props>>> & {
10
10
  "onClick:dismiss"?: (() => any) | undefined;
11
- "onClick:action"?: ((value: string | undefined) => any) | undefined;
11
+ "onClick:action"?: ((args_0: string | undefined) => any) | undefined;
12
12
  }, {}, {}>;
13
13
  export default _default;
14
14
 
@@ -25,7 +25,7 @@ declare const _default: import("vue").DefineComponent<{
25
25
  default: string;
26
26
  };
27
27
  }, {
28
- inputRef: import("vue").Ref<any>;
28
+ inputRef: import("vue").Ref<any, any>;
29
29
  computedAttrs: import("vue").ComputedRef<{
30
30
  [x: string]: unknown;
31
31
  }>;
@@ -6,10 +6,12 @@ type Content = string | Component;
6
6
  type LoadingItem = {
7
7
  id: string;
8
8
  content?: Content;
9
+ props?: Ref;
9
10
  };
10
11
  type UsePLoading = {
11
12
  show: Ref<boolean>;
12
13
  content: Content;
14
+ props: Ref;
13
15
  loadingShow: (loadingItem: LoadingItem) => void;
14
16
  loadingHide: (id: LoadingItem['id']) => void;
15
17
  };
@@ -31,10 +31,10 @@ export declare const useSelectList: (props: Props, inputSearch: InputSearch, vir
31
31
  computedItems: import("vue").ComputedRef<AnyObject[]>;
32
32
  computedItemSize: import("vue").ComputedRef<number>;
33
33
  computedInsideSelected: import("vue").ComputedRef<boolean>;
34
- internalItems: Ref<AnyObject[]>;
35
- internalValue: Ref<AnyValue[]>;
36
- search: Ref<string>;
37
- rowVirtualizer: Ref<import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>>;
34
+ internalItems: Ref<AnyObject[], AnyObject[]>;
35
+ internalValue: Ref<AnyValue[], AnyValue[]>;
36
+ search: Ref<string, string>;
37
+ rowVirtualizer: Ref<import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>, import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>>;
38
38
  getValue: (index: number) => AnyValue;
39
39
  getText: (index: number) => AnyValue;
40
40
  isSelected: (val: AnyValue) => boolean;
@@ -4,10 +4,10 @@ type Options = {
4
4
  ths: Ref<HTMLElement[]>;
5
5
  };
6
6
  export declare const usePTableColResize: (options: Options) => {
7
- isColResizing: Ref<boolean>;
8
- colResizeHandleLeft: Ref<string>;
9
- colResizingIndex: Ref<number>;
10
- colResizingWidth: Ref<number>;
7
+ isColResizing: Ref<boolean, boolean>;
8
+ colResizeHandleLeft: Ref<string, string>;
9
+ colResizingIndex: Ref<number, number>;
10
+ colResizingWidth: Ref<number, number>;
11
11
  colResize: (e: MouseEvent) => void;
12
12
  colResizeStart: (e: MouseEvent, i: number) => void;
13
13
  colResizeStop: () => void;
@@ -11,12 +11,18 @@ export declare const usePTableRowVirtualizer: (options: Options) => {
11
11
  virtualRows: Ref<{
12
12
  key: number;
13
13
  index: number;
14
+ }[], {
15
+ key: number;
16
+ index: number;
17
+ }[] | {
18
+ key: number;
19
+ index: number;
14
20
  }[]>;
15
- paddingTop: Ref<number>;
16
- paddingBottom: Ref<number>;
17
- measureElement: () => Ref<undefined>;
21
+ paddingTop: Ref<number, number>;
22
+ paddingBottom: Ref<number, number>;
23
+ measureElement: () => Ref<undefined, undefined>;
18
24
  } | {
19
- virtualizer: Ref<import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>>;
25
+ virtualizer: Ref<import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>, import("@tanstack/vue-virtual").Virtualizer<HTMLElement, Element>>;
20
26
  virtualRows: ComputedRef<import("@tanstack/vue-virtual").VirtualItem<Element>[]>;
21
27
  paddingTop: ComputedRef<number>;
22
28
  paddingBottom: ComputedRef<number>;
@@ -12,6 +12,6 @@ export declare function useInputClasses(props: Partial<Props>): {
12
12
  labelClasses: import("vue").ComputedRef<string>;
13
13
  selectClasses: import("vue").ComputedRef<string>;
14
14
  textareaClasses: import("vue").ComputedRef<string>;
15
- errorMsgClasses: import("vue").Ref<string>;
15
+ errorMsgClasses: import("vue").Ref<string, string>;
16
16
  };
17
17
  export {};
package/dist/style.css CHANGED
@@ -381,12 +381,12 @@ from {
381
381
  to {
382
382
  opacity: 0;
383
383
  }
384
- }.fadeInDown[data-v-8c0c66ab] {
384
+ }.fadeInDown[data-v-6f528d56] {
385
385
  animation-duration: 0.4s;
386
386
  animation-fill-mode: both;
387
- animation-name: fadeInDown-8c0c66ab;
387
+ animation-name: fadeInDown-6f528d56;
388
388
  }
389
- @keyframes fadeInDown-8c0c66ab {
389
+ @keyframes fadeInDown-6f528d56 {
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-8c0c66ab] {
399
+ .fadeOutUp[data-v-6f528d56] {
400
400
  animation-duration: 0.25s;
401
401
  animation-fill-mode: both;
402
- animation-name: fadeOutUp-8c0c66ab;
402
+ animation-name: fadeOutUp-6f528d56;
403
403
  }
404
- @keyframes fadeOutUp-8c0c66ab {
404
+ @keyframes fadeOutUp-6f528d56 {
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": "3.0.2",
4
+ "version": "3.1.1",
5
5
  "packageManager": "pnpm@8.9.2",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -50,67 +50,66 @@
50
50
  "vue-toastification": "^2.0.0-rc.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@babel/core": "^7.24.9",
54
- "@babel/preset-env": "^7.24.8",
53
+ "@babel/core": "^7.25.2",
54
+ "@babel/preset-env": "^7.25.3",
55
55
  "@commitlint/cli": "^19.3.0",
56
56
  "@commitlint/config-conventional": "^19.2.2",
57
57
  "@pequity/eslint-config": "^0.0.13",
58
58
  "@popperjs/core": "2.11.8",
59
59
  "@semantic-release/changelog": "^6.0.3",
60
60
  "@semantic-release/git": "^10.0.1",
61
- "@storybook/addon-a11y": "^8.2.5",
62
- "@storybook/addon-actions": "^8.2.5",
63
- "@storybook/addon-essentials": "^8.2.5",
64
- "@storybook/addon-interactions": "^8.2.5",
65
- "@storybook/addon-links": "^8.2.5",
66
- "@storybook/blocks": "^8.2.5",
67
- "@storybook/jest": "^0.2.3",
68
- "@storybook/manager-api": "^8.2.5",
61
+ "@storybook/addon-a11y": "^8.2.7",
62
+ "@storybook/addon-actions": "^8.2.7",
63
+ "@storybook/addon-essentials": "^8.2.7",
64
+ "@storybook/addon-interactions": "^8.2.7",
65
+ "@storybook/addon-links": "^8.2.7",
66
+ "@storybook/blocks": "^8.2.7",
67
+ "@storybook/manager-api": "^8.2.7",
68
+ "@storybook/test": "^8.2.7",
69
69
  "@storybook/test-runner": "^0.19.1",
70
- "@storybook/testing-library": "^0.2.2",
71
- "@storybook/theming": "^8.2.5",
72
- "@storybook/vue3": "^8.2.5",
73
- "@storybook/vue3-vite": "^8.2.5",
74
- "@tanstack/vue-virtual": "3.8.3",
70
+ "@storybook/theming": "^8.2.7",
71
+ "@storybook/vue3": "^8.2.7",
72
+ "@storybook/vue3-vite": "^8.2.7",
73
+ "@tanstack/vue-virtual": "3.8.4",
75
74
  "@types/jest": "^29.5.12",
76
75
  "@types/jsdom": "^21.1.7",
77
76
  "@types/lodash-es": "^4.17.12",
78
- "@types/node": "^20.14.11",
79
- "@vitejs/plugin-vue": "^5.0.5",
80
- "@vue/compiler-sfc": "3.4.33",
77
+ "@types/node": "^22.1.0",
78
+ "@vitejs/plugin-vue": "^5.1.2",
79
+ "@vue/compiler-sfc": "3.4.35",
81
80
  "@vue/test-utils": "^2.4.6",
82
81
  "@vue/vue3-jest": "^29.2.6",
83
82
  "autoprefixer": "^10.4.19",
84
83
  "babel-jest": "^29.7.0",
85
- "dayjs": "1.11.11",
84
+ "dayjs": "1.11.12",
86
85
  "eslint": "^8.57.0",
87
86
  "eslint-plugin-storybook": "^0.8.0",
88
87
  "floating-vue": "5.2.2",
89
- "glob": "^10.4.3",
90
- "husky": "^9.1.1",
88
+ "glob": "^10.4.5",
89
+ "husky": "^9.1.4",
91
90
  "jest": "^29.7.0",
92
91
  "jest-environment-jsdom": "^29.7.0",
93
92
  "lint-staged": "^15.2.7",
94
93
  "lodash-es": "4.17.21",
95
94
  "make-coverage-badge": "^1.2.0",
96
- "postcss": "^8.4.39",
95
+ "postcss": "^8.4.40",
97
96
  "prettier": "^3.3.3",
98
97
  "prettier-plugin-tailwindcss": "^0.6.5",
99
98
  "resolve-tspaths": "^0.8.19",
100
- "rimraf": "^5.0.8",
99
+ "rimraf": "^5.0.10",
101
100
  "sass": "^1.77.8",
102
101
  "semantic-release": "^24.0.0",
103
- "storybook": "^8.2.5",
102
+ "storybook": "^8.2.7",
104
103
  "svgo": "^3.3.2",
105
- "tailwindcss": "^3.4.6",
106
- "ts-jest": "^29.2.3",
107
- "typescript": "5.5.3",
104
+ "tailwindcss": "^3.4.7",
105
+ "ts-jest": "^29.2.4",
106
+ "typescript": "5.5.4",
108
107
  "v-calendar": "3.1.2",
109
- "vite": "^5.3.4",
110
- "vue": "3.4.32",
108
+ "vite": "^5.3.5",
109
+ "vue": "3.4.35",
111
110
  "vue-currency-input": "3.1.0",
112
- "vue-router": "4.4.0",
111
+ "vue-router": "4.4.2",
113
112
  "vue-toastification": "2.0.0-rc.5",
114
- "vue-tsc": "2.0.28"
113
+ "vue-tsc": "2.0.29"
115
114
  }
116
115
  }
@@ -62,13 +62,13 @@ describe('PActionBar.vue', () => {
62
62
  const mainDiv = await wrapper.find('.teleport-stub > .fixed.bottom-6');
63
63
  expect(mainDiv.exists()).toBe(true);
64
64
 
65
- expect(mainDiv.classes()).toEqual(['fixed', 'bottom-6', 'z-[100]', 'flex', 'w-full', 'justify-center']);
65
+ expect(mainDiv.classes()).toEqual(['fixed', 'bottom-6', 'left-1/2', 'z-[100]', '-translate-x-2/4']);
66
66
  const actionBarDiv = mainDiv.find('.bg-p-purple-60');
67
67
  expect(actionBarDiv.exists()).toBe(true);
68
68
  expect(actionBarDiv.classes()).toEqual([
69
69
  'flex',
70
70
  'h-12',
71
- 'min-w-fit',
71
+ 'w-max',
72
72
  'select-none',
73
73
  'items-center',
74
74
  'rounded-lg',
@@ -1,10 +1,39 @@
1
1
  import FileUploadIcon from '@squirrel/assets/file-upload-upload-icon.svg?inline';
2
2
  import PActionBar from '@squirrel/components/p-action-bar/p-action-bar.vue';
3
+ import PBtn from '@squirrel/components/p-btn/p-btn.vue';
3
4
  import PaginateLeftIcon from '@squirrel/assets/pagination-left-icon.svg?inline';
4
5
  import PaginateRightIcon from '@squirrel/assets/pagination-right-icon.svg?inline';
5
6
  import { action } from '@storybook/addon-actions';
7
+ import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
6
8
  import { shallowRef } from 'vue';
7
9
 
10
+ const actionBarActions = [
11
+ {
12
+ label: 'Upload',
13
+ icon: shallowRef(FileUploadIcon),
14
+ name: 'upload',
15
+ },
16
+ {
17
+ label: 'Say Hi',
18
+ name: 'greet',
19
+ },
20
+ {
21
+ label: 'Action Menu',
22
+ subActions: [
23
+ {
24
+ label: 'Subaction 1',
25
+ name: 'subaction1',
26
+ icon: shallowRef(PaginateLeftIcon),
27
+ },
28
+ {
29
+ label: 'Subaction 2',
30
+ name: 'subaction2',
31
+ icon: shallowRef(PaginateRightIcon),
32
+ },
33
+ ],
34
+ },
35
+ ];
36
+
8
37
  export default {
9
38
  title: 'Components/PActionBar',
10
39
  component: PActionBar,
@@ -27,35 +56,53 @@ export const Default = {
27
56
 
28
57
  return { args, onAction, onDismiss };
29
58
  },
30
- template: `<div class="h-20"><PActionBar v-bind="args" @click:dismiss="onDismiss" @click:action="onAction" /></div>`,
59
+ template: `
60
+ <div class="h-20">
61
+ <PActionBar v-bind="args" @click:dismiss="onDismiss" @click:action="onAction" />
62
+ </div>
63
+ `,
31
64
  }),
32
65
  args: {
33
66
  label: 'Hello World',
34
- actions: [
35
- {
36
- label: 'Upload',
37
- icon: shallowRef(FileUploadIcon),
38
- name: 'upload',
39
- },
40
- {
41
- label: 'Say Hi',
42
- name: 'greet',
43
- },
44
- {
45
- label: 'Action Menu',
46
- subActions: [
47
- {
48
- label: 'Subaction 1',
49
- name: 'subaction1',
50
- icon: shallowRef(PaginateLeftIcon),
51
- },
52
- {
53
- label: 'Subaction 2',
54
- name: 'subaction2',
55
- icon: shallowRef(PaginateRightIcon),
56
- },
57
- ],
67
+ actions: actionBarActions,
68
+ },
69
+ };
70
+
71
+ export const WithAnElementBehind = {
72
+ render: (args) => ({
73
+ components: { PActionBar, PBtn },
74
+ setup() {
75
+ const onDismiss = action('dismiss');
76
+ const onAction = action('action');
77
+
78
+ return { args, onAction, onDismiss };
79
+ },
80
+ template: `
81
+ <div class="h-20">
82
+ <div class="flex items-center fixed bottom-0 h-28 w-full z-10 bg-p-gray-30">
83
+ <PBtn @click="args.onClick">Click me!</PBtn>
84
+ </div>
85
+ <PActionBar v-bind="args" @click:dismiss="onDismiss" @click:action="onAction" />
86
+ </div>
87
+ `,
88
+ }),
89
+ args: {
90
+ label: 'Hello World',
91
+ actions: actionBarActions,
92
+ onClick: fn(),
93
+ },
94
+ play: async ({ args, canvasElement }) => {
95
+ const canvas = within(canvasElement);
96
+
97
+ await userEvent.click(canvas.getByRole('button', { name: 'Click me!' }));
98
+
99
+ await waitFor(() => expect(args.onClick).toHaveBeenCalled());
100
+ },
101
+ parameters: {
102
+ docs: {
103
+ description: {
104
+ story: 'Elements behind `PActionBar` should be clickable.',
58
105
  },
59
- ],
106
+ },
60
107
  },
61
108
  };
@@ -1,13 +1,13 @@
1
1
  <template>
2
2
  <Teleport to="body">
3
- <div class="fixed bottom-6 z-[100] flex w-full justify-center" role="alertdialog" v-bind="$attrs">
3
+ <div class="fixed bottom-6 left-1/2 z-[100] -translate-x-2/4" role="alertdialog" v-bind="$attrs">
4
4
  <div
5
- class="flex h-12 min-w-fit select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white"
5
+ class="flex h-12 w-max select-none items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white"
6
6
  >
7
7
  <PCloseBtn variant="dark" @click="$emit('click:dismiss')"></PCloseBtn>
8
8
  <p class="whitespace-nowrap px-3">{{ label }}</p>
9
9
  <div class="mx-4 h-9 w-0.5 shrink-0 rounded bg-p-purple-50"></div>
10
- <div class="flex min-w-fit">
10
+ <div class="flex">
11
11
  <template v-for="actionOrMenu in actions" :key="`action-${actionOrMenu.label}`">
12
12
  <PBtn
13
13
  v-if="!actionOrMenu.subActions"
@@ -69,8 +69,8 @@ type Props = {
69
69
  };
70
70
 
71
71
  defineEmits<{
72
- (e: 'click:dismiss'): void;
73
- (e: 'click:action', value: PActionBarAction['name']): void;
72
+ 'click:dismiss': [];
73
+ 'click:action': [PActionBarAction['name']];
74
74
  }>();
75
75
 
76
76
  defineProps<Props>();
@@ -1,6 +1,5 @@
1
1
  import PAlert from '@squirrel/components/p-alert/p-alert.vue';
2
- import { expect } from '@storybook/jest';
3
- import { within } from '@storybook/testing-library';
2
+ import { expect, within } from '@storybook/test';
4
3
 
5
4
  export default {
6
5
  title: 'Components/PAlert',
@@ -1,8 +1,7 @@
1
1
  import Icon from '@squirrel/assets/info-circle-icon.svg?inline';
2
2
  import PBtn from '@squirrel/components/p-btn/p-btn.vue';
3
3
  import { action } from '@storybook/addon-actions';
4
- import { expect } from '@storybook/jest';
5
- import { within } from '@storybook/testing-library';
4
+ import { expect, within } from '@storybook/test';
6
5
 
7
6
  // You can also import an `md` file and use it as a story's description
8
7
  // import PBtnReadme from './PBtn.readme.md';
@@ -1,7 +1,6 @@
1
1
  import PCloseBtn from '@squirrel/components/p-close-btn/p-close-btn.vue';
2
2
  import { action } from '@storybook/addon-actions';
3
- import { expect } from '@storybook/jest';
4
- import { within } from '@storybook/testing-library';
3
+ import { expect, within } from '@storybook/test';
5
4
 
6
5
  export default {
7
6
  title: 'Components/PCloseBtn',
@@ -1,6 +1,7 @@
1
1
  import PLoading from '@squirrel/components/p-loading/p-loading.vue';
2
2
  import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
3
3
  import { createWrapperFor, waitNT } from '@tests/jest.helpers';
4
+ import { defineComponent, ref } from 'vue';
4
5
  import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
5
6
 
6
7
  const createAppWrapper = () =>
@@ -218,4 +219,61 @@ describe('PLoading.vue', () => {
218
219
  });
219
220
  }).toThrowError('id is required');
220
221
  });
222
+
223
+ it(`accepts a component with reactive props as the content`, async () => {
224
+ const TestComponent = defineComponent({
225
+ name: 'TestComponent',
226
+ props: {
227
+ modelValue: {
228
+ type: Number,
229
+ required: true,
230
+ },
231
+ },
232
+ template: `<div>{{ modelValue }}</div>`,
233
+ });
234
+
235
+ const wrapper = createWrapperFor({
236
+ template: `
237
+ <button class="request-1-sec-component-props" @click="fireRequestComponentProps"></button>
238
+ <button class="update-props" @click="updateProps"></button>
239
+ `,
240
+ components: { TestComponent },
241
+ setup() {
242
+ const componentProps = ref({ modelValue: 0 });
243
+ const { loadingShow, loadingHide } = usePLoading();
244
+
245
+ const fireRequestComponentProps = async () => {
246
+ const id = `component-props`;
247
+ componentProps.value.modelValue = 10;
248
+ loadingShow({ id, content: TestComponent, props: componentProps });
249
+ await new Promise((resolve) => setTimeout(resolve, 1000));
250
+ loadingHide(id);
251
+ };
252
+
253
+ const updateProps = () => {
254
+ componentProps.value.modelValue = 20;
255
+ };
256
+
257
+ return { loadingShow, loadingHide, fireRequestComponentProps, updateProps };
258
+ },
259
+ });
260
+
261
+ await wrapper.find('.request-1-sec-component-props').trigger('click');
262
+
263
+ jest.advanceTimersByTime(300);
264
+ await waitNT(appWrapper.vm);
265
+ const testComponent = appWrapper.findComponent(TestComponent);
266
+ expect(appWrapper.find('[aria-busy]').exists()).toBe(true);
267
+ expect(testComponent.exists()).toBe(true);
268
+ expect(testComponent.props().modelValue).toBe(10);
269
+
270
+ jest.advanceTimersByTime(300);
271
+ await waitNT(appWrapper.vm);
272
+ await wrapper.find('.update-props').trigger('click');
273
+ expect(testComponent.props().modelValue).toBe(20);
274
+
275
+ jest.advanceTimersByTime(500);
276
+ await waitNT(appWrapper.vm);
277
+ expect(appWrapper.find('[aria-busy]').exists()).toBe(false);
278
+ });
221
279
  });
@@ -1,8 +1,20 @@
1
- import ComputationStatus from '@/playground/components/ComputationStatus.vue';
1
+ import ComputationStatus1 from '@/playground/components/ComputationStatus1.vue';
2
2
  import PBtn from '@squirrel/components/p-btn/p-btn.vue';
3
3
  import PLoading from '@squirrel/components/p-loading/p-loading.vue';
4
+ import { defineComponent, ref } from 'vue';
4
5
  import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
5
6
 
7
+ const TestComponent = defineComponent({
8
+ name: 'TestComponent',
9
+ props: {
10
+ modelValue: {
11
+ type: String,
12
+ default: '',
13
+ },
14
+ },
15
+ template: `<div class="text-sm px-4 py-2 whitespace-nowrap">{{ modelValue }}</div>`,
16
+ });
17
+
6
18
  export default {
7
19
  title: 'Components/PLoading',
8
20
  component: PLoading,
@@ -87,7 +99,7 @@ export const WithComponentAsContent = {
87
99
 
88
100
  const fireRequestComponent = async (time) => {
89
101
  const id = `component-${time}`;
90
- loadingShow({ id, content: ComputationStatus });
102
+ loadingShow({ id, content: ComputationStatus1 });
91
103
  await new Promise((resolve) => setTimeout(resolve, time));
92
104
  loadingHide(id);
93
105
  };
@@ -107,3 +119,46 @@ export const WithComponentAsContent = {
107
119
  `,
108
120
  }),
109
121
  };
122
+
123
+ export const WithComponentWithPropsAsContent = {
124
+ render: (args) => ({
125
+ components: { PLoading, PBtn, TestComponent },
126
+ setup() {
127
+ const { loadingShow, loadingHide } = usePLoading();
128
+ const loading = ref(false);
129
+ const componentProps = ref({ modelValue: '' });
130
+
131
+ const fireRequestComponentProps = async () => {
132
+ const id = `component-props`;
133
+ componentProps.value = { modelValue: 'Loading, please wait' };
134
+
135
+ loading.value = true;
136
+ loadingShow({ id, content: TestComponent, props: componentProps });
137
+
138
+ await new Promise((resolve) => setTimeout(resolve, 1500));
139
+
140
+ componentProps.value = { modelValue: 'Still loading...' };
141
+
142
+ await new Promise((resolve) => setTimeout(resolve, 1500));
143
+
144
+ componentProps.value = { modelValue: 'Almost there!' };
145
+
146
+ await new Promise((resolve) => setTimeout(resolve, 1500));
147
+
148
+ loadingHide(id);
149
+ loading.value = false;
150
+ };
151
+
152
+ return { args, loadingShow, fireRequestComponentProps, loading };
153
+ },
154
+ template: `
155
+ <PLoading />
156
+ <div class="mt-10">
157
+ <div>Demo with a component with props as content</div>
158
+ <div class="flex gap-4 mt-2">
159
+ <PBtn @click="fireRequestComponentProps" :disabled="loading">Display loader</PBtn>
160
+ </div>
161
+ </div>
162
+ `,
163
+ }),
164
+ };
@@ -2,18 +2,20 @@
2
2
  <Transition name="pm-backdrop-transition" enter-active-class="fadeInDown" leave-active-class="fadeOutUp">
3
3
  <div v-if="show" class="fixed left-0 top-0 z-[120] flex w-full justify-center" aria-live="polite" aria-busy="true">
4
4
  <div
5
- :style="{ width: `${width}px` }"
6
- class="h-8 overflow-hidden whitespace-nowrap rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 px-4 pt-2 text-center text-sm font-semibold leading-none text-p-purple-60 shadow-sm transition-all duration-500"
5
+ :style="{ width: `${width}px`, height: `${height}px` }"
6
+ class="overflow-hidden rounded-b border-x border-b border-p-gray-30 bg-p-blue-10 shadow-sm transition-all duration-300"
7
7
  >
8
- <Component :is="content" v-if="isComponent(content)" />
9
- <template v-else>{{ content }}</template>
8
+ <Transition enter-from-class="opacity-0" enter-active-class="transition duration-500">
9
+ <Component :is="content" v-if="isComponent(content)" v-bind="componentProps" />
10
+ <div v-else :class="textDivClass">{{ content }}</div>
11
+ </Transition>
10
12
  </div>
11
13
  </div>
12
14
  </Transition>
13
15
  <div v-if="content" class="invisible fixed">
14
- <div ref="widthReference" class="inline-flex px-4">
15
- <Component :is="content" v-if="isComponent(content)" />
16
- <template v-else>{{ content }}</template>
16
+ <div ref="dimsReference">
17
+ <Component :is="content" v-if="isComponent(content)" v-bind="componentProps" />
18
+ <div v-else :class="textDivClass">{{ content }}</div>
17
19
  </div>
18
20
  </div>
19
21
  </template>
@@ -22,19 +24,23 @@
22
24
  import { type Component, ref, toValue, watch } from 'vue';
23
25
  import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
24
26
 
27
+ const textDivClass = `overflow-hidden whitespace-nowrap px-4 pt-1 h-8 text-center text-sm font-semibold text-p-purple-60`;
28
+
25
29
  defineOptions({
26
30
  name: 'PLoading',
27
31
  });
28
32
 
29
- const { show, content } = usePLoading();
30
- const widthReference = ref<HTMLElement | null>(null);
33
+ const { show, content, props: componentProps } = usePLoading();
34
+ const dimsReference = ref<HTMLElement | null>(null);
31
35
  const width = ref(0);
36
+ const height = ref(0);
32
37
 
33
38
  watch(
34
39
  () => toValue(content),
35
40
  () => {
36
- if (widthReference.value) {
37
- width.value = widthReference.value.offsetWidth;
41
+ if (dimsReference.value) {
42
+ width.value = dimsReference.value.offsetWidth;
43
+ height.value = dimsReference.value.offsetHeight;
38
44
  }
39
45
  },
40
46
  { flush: 'post' }
@@ -9,11 +9,13 @@ type Content = string | Component;
9
9
  type LoadingItem = {
10
10
  id: string;
11
11
  content?: Content;
12
+ props?: Ref;
12
13
  };
13
14
 
14
15
  type UsePLoading = {
15
16
  show: Ref<boolean>;
16
17
  content: Content;
18
+ props: Ref;
17
19
  loadingShow: (loadingItem: LoadingItem) => void;
18
20
  loadingHide: (id: LoadingItem['id']) => void;
19
21
  };
@@ -22,6 +24,7 @@ const LOADING_TEXT = 'Loading...';
22
24
  const show = ref(false);
23
25
  const loadingItems = ref<LoadingItem[]>([]);
24
26
  const content = computed(() => loadingItems.value[loadingItems.value.length - 1]?.content);
27
+ const props = computed(() => loadingItems.value[loadingItems.value.length - 1]?.props);
25
28
  let timer: ReturnType<typeof setTimeout>;
26
29
 
27
30
  export const usePLoading = (options?: Options): UsePLoading => {
@@ -47,11 +50,21 @@ export const usePLoading = (options?: Options): UsePLoading => {
47
50
  loadingItem.content && typeof loadingItem.content === 'object'
48
51
  ? markRaw(loadingItem.content)
49
52
  : loadingItem.content || LOADING_TEXT,
53
+ props: loadingItem.props,
50
54
  });
51
55
  };
52
56
 
53
57
  const loadingHide = (id?: LoadingItem['id']) => {
54
- loadingItems.value = id && typeof id === 'string' ? loadingItems.value.filter((item) => item.id !== id) : [];
58
+ if (id && typeof id === 'string') {
59
+ const index = loadingItems.value.findIndex((item) => item.id === id);
60
+
61
+ if (index !== -1) {
62
+ loadingItems.value.splice(index, 1);
63
+ }
64
+ } else {
65
+ loadingItems.value = [];
66
+ }
67
+
55
68
  if (loadingItems.value.length === 0) {
56
69
  show.value = false;
57
70
  }
@@ -66,5 +79,5 @@ export const usePLoading = (options?: Options): UsePLoading => {
66
79
  });
67
80
  }
68
81
 
69
- return { show, content, loadingShow, loadingHide };
82
+ return { show, content, props, loadingShow, loadingHide };
70
83
  };
@@ -1,7 +1,6 @@
1
1
  import PSelectBtn from '@squirrel/components/p-select-btn/p-select-btn.vue';
2
- import { expect } from '@storybook/jest';
2
+ import { expect, userEvent, within } from '@storybook/test';
3
3
  import { fieldArgTypes } from '@root/stories/common/field';
4
- import { userEvent, within } from '@storybook/testing-library';
5
4
 
6
5
  const selectItems = Object.freeze([
7
6
  { value: 1, text: 'Aleksandr Chappel', tooltip: 'lorem ipsum text 1' },
@@ -1,8 +1,7 @@
1
1
  import PSelectPill from '@squirrel/components/p-select-pill/p-select-pill.vue';
2
- import { expect } from '@storybook/jest';
2
+ import { expect, userEvent, within } from '@storybook/test';
3
3
  import { fieldArgTypes } from '@root/stories/common/field';
4
4
  import { getCSSTransitionDuration, sleep } from '@root/stories/common/helpers';
5
- import { userEvent, within } from '@storybook/testing-library';
6
5
 
7
6
  const ACTIVE_CLASS = 'text-p-purple-60';
8
7