@pequity/squirrel 8.0.1 → 8.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.
Files changed (29) hide show
  1. package/dist/cjs/chunks/p-action-bar.js +6 -9
  2. package/dist/cjs/usePLoading.js +7 -1
  3. package/dist/es/chunks/p-action-bar.js +6 -9
  4. package/dist/es/usePLoading.js +7 -1
  5. package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +3 -2
  6. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +1 -1
  7. package/dist/squirrel/components/p-card/p-card.vue.d.ts +2 -19
  8. package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +2 -37
  9. package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +3 -2
  10. package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +2 -9
  11. package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +3 -33
  12. package/dist/squirrel/components/p-input/p-input.vue.d.ts +6 -4
  13. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +3 -107
  14. package/dist/squirrel/components/p-link/p-link.vue.d.ts +3 -11
  15. package/dist/squirrel/components/p-loading/usePLoading.d.ts +1 -0
  16. package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +2 -227
  17. package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +2 -74
  18. package/dist/squirrel/components/p-select/p-select.vue.d.ts +3 -110
  19. package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +2 -29
  20. package/dist/squirrel/components/p-table/p-table.vue.d.ts +10 -5
  21. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +1 -1
  22. package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +2 -19
  23. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +3 -72
  24. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +2 -2
  25. package/package.json +14 -14
  26. package/squirrel/components/p-action-bar/p-action-bar.spec.ts +17 -11
  27. package/squirrel/components/p-action-bar/p-action-bar.vue +6 -6
  28. package/squirrel/components/p-loading/p-loading.spec.js +35 -2
  29. package/squirrel/components/p-loading/usePLoading.ts +10 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "8.0.1",
4
+ "version": "8.0.2",
5
5
  "packageManager": "pnpm@10.6.4",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  "storybook": "storybook dev -p 6006",
19
19
  "build-storybook": "storybook build",
20
20
  "test-storybook": "test-storybook",
21
- "quality": "pnpm run lint && pnpm run typecheck && pnpm run test:unit && pnpm run build",
21
+ "quality": "pnpm run lint && pnpm run typecheck && vitest run && pnpm run build",
22
22
  "prepare": "husky"
23
23
  },
24
24
  "files": [
@@ -50,7 +50,7 @@
50
50
  "@commitlint/cli": "^19.8.0",
51
51
  "@commitlint/config-conventional": "^19.8.0",
52
52
  "@pequity/eslint-config": "^2.0.0",
53
- "@playwright/test": "^1.51.1",
53
+ "@playwright/test": "^1.52.0",
54
54
  "@semantic-release/changelog": "^6.0.3",
55
55
  "@semantic-release/git": "^10.0.1",
56
56
  "@storybook/addon-a11y": "^8.6.12",
@@ -68,21 +68,21 @@
68
68
  "@tanstack/vue-virtual": "3.13.6",
69
69
  "@types/jsdom": "^21.1.7",
70
70
  "@types/lodash-es": "^4.17.12",
71
- "@types/node": "^22.14.0",
71
+ "@types/node": "^22.15.2",
72
72
  "@vitejs/plugin-vue": "^5.2.3",
73
- "@vitest/coverage-v8": "^3.1.1",
73
+ "@vitest/coverage-v8": "^3.1.2",
74
74
  "@vue/compiler-sfc": "3.5.13",
75
75
  "@vue/test-utils": "^2.4.6",
76
76
  "@vuepic/vue-datepicker": "11.0.2",
77
77
  "autoprefixer": "^10.4.21",
78
- "eslint": "^9.24.0",
78
+ "eslint": "^9.25.1",
79
79
  "eslint-plugin-storybook": "^0.12.0",
80
80
  "floating-vue": "5.2.2",
81
- "glob": "^11.0.1",
81
+ "glob": "^11.0.2",
82
82
  "husky": "^9.1.7",
83
83
  "iconify-icon": "^2.3.0",
84
- "jsdom": "^26.0.0",
85
- "lint-staged": "^15.5.0",
84
+ "jsdom": "^26.1.0",
85
+ "lint-staged": "^15.5.1",
86
86
  "lodash-es": "4.17.21",
87
87
  "make-coverage-badge": "^1.2.0",
88
88
  "postcss": "^8.5.3",
@@ -90,19 +90,19 @@
90
90
  "prettier-plugin-tailwindcss": "^0.6.11",
91
91
  "resolve-tspaths": "^0.8.23",
92
92
  "rimraf": "^6.0.1",
93
- "sass": "^1.86.3",
93
+ "sass": "^1.87.0",
94
94
  "semantic-release": "^24.2.3",
95
95
  "storybook": "^8.6.12",
96
96
  "svgo": "^3.3.2",
97
97
  "tailwindcss": "^3.4.17",
98
98
  "typescript": "5.8.3",
99
- "vite": "^6.2.5",
100
- "vitest": "^3.1.1",
99
+ "vite": "^6.3.3",
100
+ "vitest": "^3.1.2",
101
101
  "vue": "3.5.13",
102
102
  "vue-currency-input": "3.2.1",
103
- "vue-router": "4.5.0",
103
+ "vue-router": "4.5.1",
104
104
  "vue-toastification": "2.0.0-rc.5",
105
- "vue-tsc": "2.2.8"
105
+ "vue-tsc": "2.2.10"
106
106
  },
107
107
  "dependencies": {
108
108
  "tailwind-variants": "^1.0.0"
@@ -1,5 +1,6 @@
1
1
  import PActionBar from '@squirrel/components/p-action-bar/p-action-bar.vue';
2
2
  import { createWrapperFor } from '@tests/vitest.helpers';
3
+ import { type VueWrapper } from '@vue/test-utils';
3
4
  import { defineComponent } from 'vue';
4
5
 
5
6
  const createPDropdownStub = () => {
@@ -77,7 +78,7 @@ describe('PActionBar.vue', () => {
77
78
  },
78
79
  });
79
80
 
80
- const mainDiv = await wrapper.find('.teleport-stub > .fixed.bottom-6');
81
+ const mainDiv = wrapper.find('.teleport-stub > .fixed.bottom-6');
81
82
  expect(mainDiv.exists()).toBe(true);
82
83
 
83
84
  expect(mainDiv.classes()).toEqual(['fixed', 'bottom-6', 'left-1/2', 'z-[100]', '-translate-x-2/4']);
@@ -97,14 +98,19 @@ describe('PActionBar.vue', () => {
97
98
  'text-white',
98
99
  ]);
99
100
 
100
- const paragraph = await wrapper.find('p');
101
+ const buttons = wrapper.findAllComponents({ name: 'PBtn' });
102
+ buttons.forEach((button: VueWrapper) => {
103
+ expect(button.find('.slot-wrapper > div').classes()).toEqual(['flex', 'items-center', 'gap-2', 'px-1']);
104
+ });
105
+
106
+ const paragraph = wrapper.find('p');
101
107
  expect(paragraph.text()).toContain('Hello World');
102
108
 
103
- const dismissIcon = await wrapper.find('i.x-white-icon');
109
+ const dismissIcon = wrapper.find('i.x-white-icon');
104
110
  expect(dismissIcon.exists()).toBe(true);
105
111
  expect(actionBarDiv.find('.text-xs').text()).toBe('Clear All');
106
112
 
107
- const actionBtn = await wrapper.find('button.inline-block');
113
+ const actionBtn = wrapper.find('button.inline-block');
108
114
  expect(actionBtn.exists()).toBe(true);
109
115
  expect(actionBtn.text()).toContain('Say Hi');
110
116
  });
@@ -125,9 +131,9 @@ describe('PActionBar.vue', () => {
125
131
  },
126
132
  });
127
133
 
128
- const mainDiv = await wrapper.find('.teleport-stub > .fixed.bottom-6');
134
+ const mainDiv = wrapper.find('.teleport-stub > .fixed.bottom-6');
129
135
 
130
- await mainDiv.find('.p-dropdown-stub > button').trigger('click');
136
+ mainDiv.find('.p-dropdown-stub > button').trigger('click');
131
137
 
132
138
  await wrapper.vm.$nextTick();
133
139
 
@@ -155,7 +161,7 @@ describe('PActionBar.vue', () => {
155
161
  },
156
162
  });
157
163
 
158
- const actionBar = await wrapper.find('.teleport-stub > div');
164
+ const actionBar = wrapper.find('.teleport-stub > div');
159
165
 
160
166
  expect(actionBar.attributes('role')).toBe('alertdialog');
161
167
  expect(actionBar.attributes('data-testid')).toBe('TestId');
@@ -168,7 +174,7 @@ describe('PActionBar.vue', () => {
168
174
  props: { show: true, label: 'Hello World', actions: [{ label: 'Say Hi', name: 'greet' }] },
169
175
  });
170
176
 
171
- const button = await wrapper.find('button.inline-flex');
177
+ const button = wrapper.find('button.inline-flex');
172
178
 
173
179
  await button.trigger('click');
174
180
 
@@ -187,15 +193,15 @@ describe('PActionBar.vue', () => {
187
193
  },
188
194
  });
189
195
 
190
- const button = await wrapper.findByText('Say Hi', 'button');
196
+ const button = wrapper.findByText('Say Hi', 'button');
191
197
  await button.trigger('click');
192
198
 
193
199
  expect(wrapper.emitted()['click:action'][0]).toEqual(['greet']);
194
200
 
195
- const actionMenu = await wrapper.findByText('Action menu', 'button');
201
+ const actionMenu = wrapper.findByText('Action menu', 'button');
196
202
  await actionMenu.trigger('click');
197
203
 
198
- const subAction = await wrapper.findByText('Say Bye', 'button');
204
+ const subAction = wrapper.findByText('Say Bye', 'button');
199
205
  await subAction.trigger('click');
200
206
 
201
207
  expect(wrapper.emitted()['click:action'][1]).toEqual(['bye']);
@@ -19,17 +19,17 @@
19
19
  type="secondary-ghost-dark"
20
20
  @click="$emit('click:action', actionOrMenu.name)"
21
21
  >
22
- <div class="flex items-center gap-2 px-1 py-0.5">
22
+ <div class="flex items-center gap-2 px-1">
23
23
  <Component :is="actionOrMenu.icon" v-if="isComponent(actionOrMenu.icon)" class="h-4 w-4" />
24
- <PIcon v-if="isString(actionOrMenu.icon)" :icon="actionOrMenu.icon" width="16px" height="16px" />
24
+ <PIcon v-if="isString(actionOrMenu.icon)" :icon="actionOrMenu.icon" width="16" />
25
25
  <div>{{ actionOrMenu.label }}</div>
26
26
  </div>
27
27
  </PBtn>
28
28
  <PDropdown v-else placement="top" strategy="fixed">
29
29
  <PBtn size="sm" type="secondary-ghost-dark">
30
- <div class="flex items-center gap-2 px-1 py-0.5">
30
+ <div class="flex items-center gap-2 px-1">
31
31
  <Component :is="actionOrMenu.icon" v-if="isComponent(actionOrMenu.icon)" class="h-4 w-4" />
32
- <PIcon v-if="isString(actionOrMenu.icon)" :icon="actionOrMenu.icon" width="16px" height="16px" />
32
+ <PIcon v-if="isString(actionOrMenu.icon)" :icon="actionOrMenu.icon" width="16" />
33
33
  <div>{{ actionOrMenu.label }}</div>
34
34
  </div>
35
35
  </PBtn>
@@ -42,9 +42,9 @@
42
42
  type="secondary-ghost-dark"
43
43
  @click="($emit('click:action', subaction.name), hide())"
44
44
  >
45
- <div class="flex items-center gap-2 px-1 py-0.5">
45
+ <div class="flex items-center gap-2 px-1">
46
46
  <Component :is="subaction.icon" v-if="isComponent(subaction.icon)" class="h-4 w-4" />
47
- <PIcon v-if="isString(subaction.icon)" :icon="subaction.icon" width="16px" height="16px" />
47
+ <PIcon v-if="isString(subaction.icon)" :icon="subaction.icon" width="16" />
48
48
  <div>{{ subaction.label }}</div>
49
49
  </div>
50
50
  </PBtn>
@@ -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, show } = usePLoading(options);
27
+ const { loadingShow, loadingHide, show, isLoading } = 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, show };
50
+ return { loadingShow, loadingHide, fireRequest, fireRequestText, fireRequestComponent, show, isLoading };
51
51
  },
52
52
  },
53
53
  {
@@ -90,6 +90,39 @@ describe('PLoading.vue', () => {
90
90
  expect(appWrapper.find('[aria-busy]').exists()).toBe(false);
91
91
  });
92
92
 
93
+ it('correctly reports loading state for a single loader', async () => {
94
+ const wrapper = createWrapper({ delay: 0 });
95
+
96
+ await wrapper.find('.request-1-sec').trigger('click');
97
+
98
+ vi.advanceTimersByTime(500);
99
+ await waitNT(appWrapper.vm);
100
+ expect(wrapper.vm.isLoading('default-1000')).toBe(true);
101
+
102
+ vi.advanceTimersByTime(600);
103
+ await waitNT(appWrapper.vm);
104
+ expect(wrapper.vm.isLoading('default-1000')).toBe(false);
105
+ });
106
+
107
+ it('correctly reports loading state for multiple loaders', async () => {
108
+ const wrapper = createWrapper({ delay: 0 });
109
+
110
+ await wrapper.find('.request-1-sec').trigger('click');
111
+ await wrapper.find('.request-3-secs').trigger('click');
112
+
113
+ vi.advanceTimersByTime(500);
114
+ await waitNT(appWrapper.vm);
115
+ expect(wrapper.vm.isLoading()).toBe(true);
116
+
117
+ vi.advanceTimersByTime(1000);
118
+ await waitNT(appWrapper.vm);
119
+ expect(wrapper.vm.isLoading()).toBe(true);
120
+
121
+ vi.advanceTimersByTime(2000);
122
+ await waitNT(appWrapper.vm);
123
+ expect(wrapper.vm.isLoading()).toBe(false);
124
+ });
125
+
93
126
  it(`doesn't show the loading indicator when loadingHide gets called before the delay time has passed`, async () => {
94
127
  const wrapper = createWrapper({ delay: 1000 });
95
128
 
@@ -22,6 +22,7 @@ type UsePLoading = {
22
22
  props: Ref;
23
23
  loadingShow: (loadingItem: LoadingItemOption) => void;
24
24
  loadingHide: (id?: LoadingItemOption['id']) => void;
25
+ isLoading: (id?: LoadingItemOption['id']) => boolean;
25
26
  };
26
27
 
27
28
  const LOADING_TEXT = 'Loading...';
@@ -86,6 +87,14 @@ export const usePLoading = (options?: Options): UsePLoading => {
86
87
  }
87
88
  };
88
89
 
90
+ const isLoading = (id?: LoadingItemOption['id']) => {
91
+ if (id) {
92
+ return loadingItems.value.some((item) => item.id === id);
93
+ }
94
+
95
+ return loadingItems.value.length > 0;
96
+ };
97
+
89
98
  if (scope) {
90
99
  onScopeDispose(() => {
91
100
  if (loadingItems.value.some((item) => item.clearOnDispose === false)) {
@@ -102,5 +111,5 @@ export const usePLoading = (options?: Options): UsePLoading => {
102
111
  });
103
112
  }
104
113
 
105
- return { show, content, props, loadingShow, loadingHide };
114
+ return { show, content, props, loadingShow, loadingHide, isLoading };
106
115
  };