@pequity/squirrel 5.4.2 → 5.4.4

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.
package/dist/cjs/index.js CHANGED
@@ -445,6 +445,13 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
445
445
  closePopperOnSelect: {
446
446
  type: Boolean,
447
447
  default: true
448
+ },
449
+ /**
450
+ * Focus the search input on mount
451
+ */
452
+ focusSearchOnMount: {
453
+ type: Boolean,
454
+ default: true
448
455
  }
449
456
  },
450
457
  emits: ["update:modelValue", "select"],
@@ -487,7 +494,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
487
494
  scrollerStyle.value = { maxHeight: `${computedItemSize.value * props.itemsVisible - actionsContainerHeight}px` };
488
495
  putSelectedItemsOnTop();
489
496
  if (props.searchable) {
490
- (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
497
+ props.focusSearchOnMount && ((_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus());
491
498
  } else {
492
499
  setupNavigationSvc();
493
500
  }
@@ -20,10 +20,12 @@ const usePTableRowVirtualizer = (options) => {
20
20
  );
21
21
  const measureElement = (cmp) => {
22
22
  const el = vue.isRef(cmp) ? vue.unref(cmp) : cmp == null ? void 0 : cmp.$el;
23
- if (!el) {
24
- return;
25
- }
26
- virtualizer.value.measureElement(el);
23
+ vue.nextTick(() => {
24
+ if (!el) {
25
+ return;
26
+ }
27
+ virtualizer.value.measureElement(el);
28
+ });
27
29
  return void 0;
28
30
  };
29
31
  return { virtualizer, virtualRows, paddingTop, paddingBottom, measureElement };
package/dist/es/index.js CHANGED
@@ -445,6 +445,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
445
445
  closePopperOnSelect: {
446
446
  type: Boolean,
447
447
  default: true
448
+ },
449
+ /**
450
+ * Focus the search input on mount
451
+ */
452
+ focusSearchOnMount: {
453
+ type: Boolean,
454
+ default: true
448
455
  }
449
456
  },
450
457
  emits: ["update:modelValue", "select"],
@@ -487,7 +494,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
487
494
  scrollerStyle.value = { maxHeight: `${computedItemSize.value * props.itemsVisible - actionsContainerHeight}px` };
488
495
  putSelectedItemsOnTop();
489
496
  if (props.searchable) {
490
- (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
497
+ props.focusSearchOnMount && ((_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus());
491
498
  } else {
492
499
  setupNavigationSvc();
493
500
  }
@@ -1,4 +1,4 @@
1
- import { ref, computed, isRef, unref } from "vue";
1
+ import { ref, computed, isRef, unref, nextTick } from "vue";
2
2
  import { useVirtualizer } from "@tanstack/vue-virtual";
3
3
  const usePTableRowVirtualizer = (options) => {
4
4
  if (!options.value) {
@@ -18,10 +18,12 @@ const usePTableRowVirtualizer = (options) => {
18
18
  );
19
19
  const measureElement = (cmp) => {
20
20
  const el = isRef(cmp) ? unref(cmp) : cmp == null ? void 0 : cmp.$el;
21
- if (!el) {
22
- return;
23
- }
24
- virtualizer.value.measureElement(el);
21
+ nextTick(() => {
22
+ if (!el) {
23
+ return;
24
+ }
25
+ virtualizer.value.measureElement(el);
26
+ });
25
27
  return void 0;
26
28
  };
27
29
  return { virtualizer, virtualRows, paddingTop, paddingBottom, measureElement };
@@ -324,6 +324,13 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
324
324
  type: BooleanConstructor;
325
325
  default: boolean;
326
326
  };
327
+ /**
328
+ * Focus the search input on mount
329
+ */
330
+ focusSearchOnMount: {
331
+ type: BooleanConstructor;
332
+ default: boolean;
333
+ };
327
334
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
328
335
  select: (...args: any[]) => void;
329
336
  "update:modelValue": (...args: any[]) => void;
@@ -435,6 +442,13 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
435
442
  type: BooleanConstructor;
436
443
  default: boolean;
437
444
  };
445
+ /**
446
+ * Focus the search input on mount
447
+ */
448
+ focusSearchOnMount: {
449
+ type: BooleanConstructor;
450
+ default: boolean;
451
+ };
438
452
  }>> & Readonly<{
439
453
  onSelect?: ((...args: any[]) => any) | undefined;
440
454
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -457,6 +471,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
457
471
  selectedTopShown: boolean;
458
472
  topSectionClass: string;
459
473
  closePopperOnSelect: boolean;
474
+ focusSearchOnMount: boolean;
460
475
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
461
476
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
462
477
  export default _default;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "5.4.2",
5
- "packageManager": "pnpm@9.12.1",
4
+ "version": "5.4.4",
5
+ "packageManager": "pnpm@9.12.2",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "preinstall": "npx only-allow pnpm",
@@ -53,26 +53,26 @@
53
53
  "@commitlint/cli": "^19.5.0",
54
54
  "@commitlint/config-conventional": "^19.5.0",
55
55
  "@pequity/eslint-config": "^0.0.13",
56
- "@playwright/test": "^1.48.0",
56
+ "@playwright/test": "^1.48.1",
57
57
  "@popperjs/core": "2.11.8",
58
58
  "@semantic-release/changelog": "^6.0.3",
59
59
  "@semantic-release/git": "^10.0.1",
60
- "@storybook/addon-a11y": "^8.3.5",
61
- "@storybook/addon-actions": "^8.3.5",
62
- "@storybook/addon-essentials": "^8.3.5",
63
- "@storybook/addon-interactions": "^8.3.5",
64
- "@storybook/addon-links": "^8.3.5",
65
- "@storybook/blocks": "^8.3.5",
66
- "@storybook/manager-api": "^8.3.5",
67
- "@storybook/test": "^8.3.5",
60
+ "@storybook/addon-a11y": "^8.3.6",
61
+ "@storybook/addon-actions": "^8.3.6",
62
+ "@storybook/addon-essentials": "^8.3.6",
63
+ "@storybook/addon-interactions": "^8.3.6",
64
+ "@storybook/addon-links": "^8.3.6",
65
+ "@storybook/blocks": "^8.3.6",
66
+ "@storybook/manager-api": "^8.3.6",
67
+ "@storybook/test": "^8.3.6",
68
68
  "@storybook/test-runner": "^0.19.1",
69
- "@storybook/theming": "^8.3.5",
70
- "@storybook/vue3": "^8.3.5",
71
- "@storybook/vue3-vite": "^8.3.5",
69
+ "@storybook/theming": "^8.3.6",
70
+ "@storybook/vue3": "^8.3.6",
71
+ "@storybook/vue3-vite": "^8.3.6",
72
72
  "@tanstack/vue-virtual": "3.10.8",
73
73
  "@types/jsdom": "^21.1.7",
74
74
  "@types/lodash-es": "^4.17.12",
75
- "@types/node": "^22.7.5",
75
+ "@types/node": "^22.7.6",
76
76
  "@vitejs/plugin-vue": "^5.1.4",
77
77
  "@vitest/coverage-v8": "^2.1.3",
78
78
  "@vue/compiler-sfc": "3.5.12",
@@ -94,11 +94,11 @@
94
94
  "prettier-plugin-tailwindcss": "^0.6.8",
95
95
  "resolve-tspaths": "^0.8.22",
96
96
  "rimraf": "^6.0.1",
97
- "sass": "^1.79.5",
97
+ "sass": "^1.80.2",
98
98
  "semantic-release": "^24.1.2",
99
- "storybook": "^8.3.5",
99
+ "storybook": "^8.3.6",
100
100
  "svgo": "^3.3.2",
101
- "tailwindcss": "^3.4.13",
101
+ "tailwindcss": "^3.4.14",
102
102
  "typescript": "5.6.3",
103
103
  "v-calendar": "3.1.2",
104
104
  "vite": "^5.4.9",
@@ -89,6 +89,32 @@ describe('PSelectList.vue', () => {
89
89
  cleanup(wrapper);
90
90
  });
91
91
 
92
+ it('focuses on the search input on mount', async () => {
93
+ useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
94
+
95
+ const wrapper = createWrapper({ selected: 17 }, { searchable: true, focusSearchOnMount: true });
96
+
97
+ const inputSearch = wrapper.findComponent({ name: 'PInputSearch' });
98
+
99
+ expect(inputSearch.exists()).toBe(true);
100
+ expect(inputSearch.element.querySelector('input')).toBe(document.activeElement);
101
+
102
+ cleanup(wrapper);
103
+ });
104
+
105
+ it('does not focus on the search input on mount', async () => {
106
+ useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
107
+
108
+ const wrapper = createWrapper({ selected: 17 }, { searchable: true, focusSearchOnMount: false });
109
+
110
+ const inputSearch = wrapper.findComponent({ name: 'PInputSearch' });
111
+
112
+ expect(inputSearch.exists()).toBe(true);
113
+ expect(inputSearch.element.querySelector('input')).not.toBe(document.activeElement);
114
+
115
+ cleanup(wrapper);
116
+ });
117
+
92
118
  it('emits the selected value when clicked (v-model)', async () => {
93
119
  useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
94
120
 
@@ -251,6 +251,13 @@ const props = defineProps({
251
251
  type: Boolean,
252
252
  default: true,
253
253
  },
254
+ /**
255
+ * Focus the search input on mount
256
+ */
257
+ focusSearchOnMount: {
258
+ type: Boolean,
259
+ default: true,
260
+ },
254
261
  });
255
262
 
256
263
  // Data
@@ -298,7 +305,7 @@ onMounted(async () => {
298
305
  putSelectedItemsOnTop();
299
306
 
300
307
  if (props.searchable) {
301
- inputSearch.value?.$el.querySelector('input').focus();
308
+ props.focusSearchOnMount && inputSearch.value?.$el.querySelector('input').focus();
302
309
  } else {
303
310
  setupNavigationSvc();
304
311
  }
@@ -1,4 +1,4 @@
1
- import { type ComponentPublicInstance, type ComputedRef, type Ref, computed, isRef, ref, unref } from 'vue';
1
+ import { type ComponentPublicInstance, type ComputedRef, type Ref, computed, isRef, nextTick, ref, unref } from 'vue';
2
2
  import { useVirtualizer } from '@tanstack/vue-virtual';
3
3
 
4
4
  type Options = ComputedRef<{
@@ -35,11 +35,13 @@ export const usePTableRowVirtualizer = (options: Options) => {
35
35
  const measureElement = (cmp: ComponentPublicInstance | Ref<HTMLElement>) => {
36
36
  const el = isRef(cmp) ? unref(cmp) : cmp?.$el;
37
37
 
38
- if (!el) {
39
- return;
40
- }
38
+ nextTick(() => {
39
+ if (!el) {
40
+ return;
41
+ }
41
42
 
42
- virtualizer.value.measureElement(el);
43
+ virtualizer.value.measureElement(el);
44
+ });
43
45
 
44
46
  return undefined;
45
47
  };