@pequity/squirrel 8.2.1 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,18 +103,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
103
103
  default: "500px"
104
104
  }
105
105
  },
106
- emits: [
107
- "before-open",
108
- "opening",
109
- "opened",
110
- "before-close",
111
- "closing",
112
- "closed",
113
- "update:modelValue"
114
- ],
106
+ emits: ["before-open", "opening", "opened", "before-close", "closing", "closed", "update:modelValue", "click:overlay"],
115
107
  setup(__props, { emit: __emit }) {
116
108
  vue.useCssVars((_ctx) => ({
117
- "9a05239e": __props.maxWidth
109
+ "56e8ccbe": __props.maxWidth
118
110
  }));
119
111
  let animatingZIndex = 0;
120
112
  const emit = __emit;
@@ -162,7 +154,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
162
154
  props.name && modal.hide(props.name);
163
155
  }
164
156
  };
165
- const clickOutside = (e) => {
157
+ const overlayClick = (e) => {
158
+ emit("click:overlay", e);
166
159
  if (e.target === pmWrapper.value) {
167
160
  close();
168
161
  }
@@ -310,7 +303,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
310
303
  "aria-modal": "true",
311
304
  "aria-describedby": `${id.value}-content`,
312
305
  "aria-labelledby": `${id.value}-title`,
313
- onClick: _cache[0] || (_cache[0] = ($event) => clickOutside($event)),
306
+ onClick: _cache[0] || (_cache[0] = ($event) => overlayClick($event)),
314
307
  onKeydown: _cache[1] || (_cache[1] = ($event) => keydown($event))
315
308
  }, [
316
309
  vue.createElementVNode("div", {
@@ -371,5 +364,5 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
371
364
  };
372
365
  }
373
366
  });
374
- const pModal = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-c3379c94"]]);
367
+ const pModal = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-18201676"]]);
375
368
  module.exports = pModal;
@@ -102,18 +102,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
102
102
  default: "500px"
103
103
  }
104
104
  },
105
- emits: [
106
- "before-open",
107
- "opening",
108
- "opened",
109
- "before-close",
110
- "closing",
111
- "closed",
112
- "update:modelValue"
113
- ],
105
+ emits: ["before-open", "opening", "opened", "before-close", "closing", "closed", "update:modelValue", "click:overlay"],
114
106
  setup(__props, { emit: __emit }) {
115
107
  useCssVars((_ctx) => ({
116
- "9a05239e": __props.maxWidth
108
+ "56e8ccbe": __props.maxWidth
117
109
  }));
118
110
  let animatingZIndex = 0;
119
111
  const emit = __emit;
@@ -161,7 +153,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
161
153
  props.name && modal.hide(props.name);
162
154
  }
163
155
  };
164
- const clickOutside = (e) => {
156
+ const overlayClick = (e) => {
157
+ emit("click:overlay", e);
165
158
  if (e.target === pmWrapper.value) {
166
159
  close();
167
160
  }
@@ -309,7 +302,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
309
302
  "aria-modal": "true",
310
303
  "aria-describedby": `${id.value}-content`,
311
304
  "aria-labelledby": `${id.value}-title`,
312
- onClick: _cache[0] || (_cache[0] = ($event) => clickOutside($event)),
305
+ onClick: _cache[0] || (_cache[0] = ($event) => overlayClick($event)),
313
306
  onKeydown: _cache[1] || (_cache[1] = ($event) => keydown($event))
314
307
  }, [
315
308
  createElementVNode("div", {
@@ -370,7 +363,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
370
363
  };
371
364
  }
372
365
  });
373
- const pModal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c3379c94"]]);
366
+ const pModal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-18201676"]]);
374
367
  export {
375
368
  pModal as default
376
369
  };
@@ -89,13 +89,14 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
89
89
  default: string;
90
90
  };
91
91
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
92
- "update:modelValue": (...args: any[]) => void;
93
- closed: (...args: any[]) => void;
94
- "before-open": (...args: any[]) => void;
95
- opening: (...args: any[]) => void;
96
- opened: (...args: any[]) => void;
97
- "before-close": (...args: any[]) => void;
98
- closing: (...args: any[]) => void;
92
+ "update:modelValue": (args_0: boolean) => any;
93
+ closed: () => any;
94
+ "before-open": () => any;
95
+ opening: () => any;
96
+ opened: () => any;
97
+ "before-close": () => any;
98
+ closing: () => any;
99
+ "click:overlay": (args_0: MouseEvent) => any;
99
100
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
100
101
  name: {
101
102
  type: StringConstructor;
@@ -174,13 +175,14 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
174
175
  default: string;
175
176
  };
176
177
  }>> & Readonly<{
177
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
178
- onClosed?: ((...args: any[]) => any) | undefined;
179
- "onBefore-open"?: ((...args: any[]) => any) | undefined;
180
- onOpening?: ((...args: any[]) => any) | undefined;
181
- onOpened?: ((...args: any[]) => any) | undefined;
182
- "onBefore-close"?: ((...args: any[]) => any) | undefined;
183
- onClosing?: ((...args: any[]) => any) | undefined;
178
+ "onUpdate:modelValue"?: ((args_0: boolean) => any) | undefined;
179
+ onClosed?: (() => any) | undefined;
180
+ "onBefore-open"?: (() => any) | undefined;
181
+ onOpening?: (() => any) | undefined;
182
+ onOpened?: (() => any) | undefined;
183
+ "onBefore-close"?: (() => any) | undefined;
184
+ onClosing?: (() => any) | undefined;
185
+ "onClick:overlay"?: ((args_0: MouseEvent) => any) | undefined;
184
186
  }>, {
185
187
  name: string;
186
188
  title: string;
package/dist/squirrel.css CHANGED
@@ -295,33 +295,33 @@ to {
295
295
  opacity: 0;
296
296
  transform: translate3d(0, -100%, 0);
297
297
  }
298
- }.pm[data-v-c3379c94] {
298
+ }.pm[data-v-18201676] {
299
299
  width: calc(100% - 32px);
300
300
  min-width: 110px;
301
- max-width: var(--9a05239e);
301
+ max-width: var(--56e8ccbe);
302
302
  max-height: calc(100vh - 32px);
303
303
  }
304
- .fadeIn[data-v-c3379c94] {
304
+ .fadeIn[data-v-18201676] {
305
305
  animation-duration: 0.4s;
306
- animation-name: fadeInFrames-c3379c94;
306
+ animation-name: fadeInFrames-18201676;
307
307
  animation-fill-mode: both;
308
308
  }
309
- .fadeOut[data-v-c3379c94] {
309
+ .fadeOut[data-v-18201676] {
310
310
  animation-duration: 0.2s;
311
- animation-name: fadeOutFrames-c3379c94;
311
+ animation-name: fadeOutFrames-18201676;
312
312
  animation-fill-mode: both;
313
313
  }
314
- .slideInTop[data-v-c3379c94] {
314
+ .slideInTop[data-v-18201676] {
315
315
  animation-duration: 0.4s;
316
- animation-name: fadeInFrames-c3379c94,slideInTopFrames-c3379c94;
316
+ animation-name: fadeInFrames-18201676,slideInTopFrames-18201676;
317
317
  animation-fill-mode: both;
318
318
  }
319
- .slideOutTop[data-v-c3379c94] {
319
+ .slideOutTop[data-v-18201676] {
320
320
  animation-duration: 0.2s;
321
- animation-name: fadeOutFrames-c3379c94,slideOutTopFrames-c3379c94;
321
+ animation-name: fadeOutFrames-18201676,slideOutTopFrames-18201676;
322
322
  animation-fill-mode: both;
323
323
  }
324
- @keyframes slideInTopFrames-c3379c94 {
324
+ @keyframes slideInTopFrames-18201676 {
325
325
  from {
326
326
  transform: translate(0, -12px);
327
327
  animation-timing-function: cubic-bezier(0, 0, 0, 1);
@@ -330,7 +330,7 @@ to {
330
330
  transform: translate(0, 0);
331
331
  }
332
332
  }
333
- @keyframes slideOutTopFrames-c3379c94 {
333
+ @keyframes slideOutTopFrames-18201676 {
334
334
  from {
335
335
  transform: translate(0, 0);
336
336
  animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1);
@@ -339,7 +339,7 @@ to {
339
339
  transform: translate(0, -12px);
340
340
  }
341
341
  }
342
- @keyframes fadeInFrames-c3379c94 {
342
+ @keyframes fadeInFrames-18201676 {
343
343
  from {
344
344
  opacity: 0;
345
345
  animation-timing-function: cubic-bezier(0, 0, 1, 1);
@@ -348,7 +348,7 @@ to {
348
348
  opacity: 1;
349
349
  }
350
350
  }
351
- @keyframes fadeOutFrames-c3379c94 {
351
+ @keyframes fadeOutFrames-18201676 {
352
352
  from {
353
353
  opacity: 1;
354
354
  animation-timing-function: cubic-bezier(0.33, 0, 0.67, 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.2.1",
4
+ "version": "8.3.0",
5
5
  "packageManager": "pnpm@10.6.4",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -53,29 +53,29 @@
53
53
  "@playwright/test": "^1.52.0",
54
54
  "@semantic-release/changelog": "^6.0.3",
55
55
  "@semantic-release/git": "^10.0.1",
56
- "@storybook/addon-a11y": "^8.6.12",
57
- "@storybook/addon-actions": "^8.6.12",
58
- "@storybook/addon-essentials": "^8.6.12",
59
- "@storybook/addon-interactions": "^8.6.12",
60
- "@storybook/addon-links": "^8.6.12",
61
- "@storybook/blocks": "^8.6.12",
62
- "@storybook/manager-api": "^8.6.12",
63
- "@storybook/test": "^8.6.12",
56
+ "@storybook/addon-a11y": "^8.6.14",
57
+ "@storybook/addon-actions": "^8.6.14",
58
+ "@storybook/addon-essentials": "^8.6.14",
59
+ "@storybook/addon-interactions": "^8.6.14",
60
+ "@storybook/addon-links": "^8.6.14",
61
+ "@storybook/blocks": "^8.6.14",
62
+ "@storybook/manager-api": "^8.6.14",
63
+ "@storybook/test": "^8.6.14",
64
64
  "@storybook/test-runner": "^0.22.0",
65
- "@storybook/theming": "^8.6.12",
66
- "@storybook/vue3": "^8.6.12",
67
- "@storybook/vue3-vite": "^8.6.12",
65
+ "@storybook/theming": "^8.6.14",
66
+ "@storybook/vue3": "^8.6.14",
67
+ "@storybook/vue3-vite": "^8.6.14",
68
68
  "@tanstack/vue-virtual": "3.13.8",
69
69
  "@types/jsdom": "^21.1.7",
70
70
  "@types/lodash-es": "^4.17.12",
71
- "@types/node": "^22.15.18",
71
+ "@types/node": "^22.15.19",
72
72
  "@vitejs/plugin-vue": "^5.2.4",
73
73
  "@vitest/coverage-v8": "^3.1.3",
74
- "@vue/compiler-sfc": "3.5.13",
74
+ "@vue/compiler-sfc": "3.5.14",
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.26.0",
78
+ "eslint": "^9.27.0",
79
79
  "eslint-plugin-storybook": "^0.12.0",
80
80
  "floating-vue": "5.2.2",
81
81
  "glob": "^11.0.2",
@@ -90,15 +90,15 @@
90
90
  "prettier-plugin-tailwindcss": "^0.6.11",
91
91
  "resolve-tspaths": "^0.8.23",
92
92
  "rimraf": "^6.0.1",
93
- "sass": "^1.88.0",
94
- "semantic-release": "^24.2.3",
95
- "storybook": "^8.6.12",
93
+ "sass": "^1.89.0",
94
+ "semantic-release": "^24.2.4",
95
+ "storybook": "^8.6.14",
96
96
  "svgo": "^3.3.2",
97
97
  "tailwindcss": "^3.4.17",
98
98
  "typescript": "5.8.3",
99
99
  "vite": "^6.3.5",
100
100
  "vitest": "^3.1.3",
101
- "vue": "3.5.13",
101
+ "vue": "3.5.14",
102
102
  "vue-currency-input": "3.2.1",
103
103
  "vue-router": "4.5.1",
104
104
  "vue-toastification": "2.0.0-rc.5",
@@ -2,17 +2,35 @@ import PModal from '@squirrel/components/p-modal/p-modal.vue';
2
2
  import { sleep, waitRAF } from '@tests/vitest.helpers';
3
3
  import { mount } from '@vue/test-utils';
4
4
 
5
- const createWrapper = () => {
6
- return mount(PModal, {
5
+ const createWrapperContainer = (componentArgs) => {
6
+ const args = componentArgs || {};
7
+
8
+ args.appendTo = '#modal-host';
9
+
10
+ const wrapperContainer = {
11
+ components: {
12
+ PModal,
13
+ },
14
+ data() {
15
+ return {
16
+ showModal: false,
17
+ args,
18
+ };
19
+ },
20
+ template: `
21
+ <button @click="showModal = !showModal">Toggle modal</button>
22
+ <div id="modal-host"></div>
23
+ <PModal v-model="showModal" v-bind="args"><p>Modal content goes here...</p></PModal>
24
+ `,
25
+ };
26
+
27
+ return mount(wrapperContainer, {
7
28
  attachTo: document.body,
8
29
  global: {
9
30
  stubs: {
10
31
  transition: false,
11
32
  },
12
33
  },
13
- slots: {
14
- default: '<p>Modal content goes here...</p>',
15
- },
16
34
  });
17
35
  };
18
36
 
@@ -22,24 +40,39 @@ describe('Modal events', () => {
22
40
  });
23
41
 
24
42
  it.each(['before-open', 'opening', 'opened'])('emits a %s event when opening', async (eventName) => {
25
- const wrapper = createWrapper();
43
+ const wrapper = createWrapperContainer();
44
+ const modal = wrapper.findComponent(PModal);
26
45
 
27
- await wrapper.setProps({ modelValue: true });
46
+ await wrapper.find('button').trigger('click');
28
47
  await waitRAF();
29
48
  await sleep(200);
30
- expect(wrapper.emitted()[eventName]).toBeTruthy();
49
+ expect(modal.emitted()[eventName]).toBeTruthy();
31
50
  wrapper.unmount();
32
51
  });
33
52
 
34
53
  it.each(['before-close', 'closing', 'closed'])('emits a %s event when closing', async (eventName) => {
35
- const wrapper = createWrapper();
54
+ const wrapper = createWrapperContainer();
55
+ const modal = wrapper.findComponent(PModal);
36
56
 
37
- await wrapper.setProps({ modelValue: true });
57
+ await wrapper.find('button').trigger('click');
38
58
  await waitRAF();
39
- await wrapper.setProps({ modelValue: false });
59
+ await wrapper.find('button').trigger('click');
40
60
  await waitRAF();
41
61
  await sleep(200);
42
- expect(wrapper.emitted()[eventName]).toBeTruthy();
62
+ expect(modal.emitted()[eventName]).toBeTruthy();
63
+ wrapper.unmount();
64
+ });
65
+
66
+ it('emits a click:overlay event when clicking on the overlay', async () => {
67
+ const wrapper = createWrapperContainer();
68
+ const modal = wrapper.findComponent(PModal);
69
+
70
+ await wrapper.find('button').trigger('click');
71
+ await waitRAF();
72
+
73
+ await wrapper.find('[role="dialog"]').trigger('click');
74
+
75
+ expect(modal.emitted('click:overlay')).toBeTruthy();
43
76
  wrapper.unmount();
44
77
  });
45
78
  });
@@ -26,7 +26,7 @@
26
26
  aria-modal="true"
27
27
  :aria-describedby="`${id}-content`"
28
28
  :aria-labelledby="`${id}-title`"
29
- @click="clickOutside($event)"
29
+ @click="overlayClick($event)"
30
30
  @keydown="keydown($event)"
31
31
  >
32
32
  <div ref="pm" :data-pm-id="id" :class="modalClass" :style="modalStyle">
@@ -94,15 +94,16 @@ defineOptions({
94
94
  name: 'PModal',
95
95
  });
96
96
 
97
- const emit = defineEmits([
98
- 'before-open',
99
- 'opening',
100
- 'opened',
101
- 'before-close',
102
- 'closing',
103
- 'closed',
104
- 'update:modelValue',
105
- ]);
97
+ const emit = defineEmits<{
98
+ 'before-open': [];
99
+ opening: [];
100
+ opened: [];
101
+ 'before-close': [];
102
+ closing: [];
103
+ closed: [];
104
+ 'update:modelValue': [boolean];
105
+ 'click:overlay': [MouseEvent];
106
+ }>();
106
107
 
107
108
  const props = defineProps({
108
109
  name: {
@@ -234,7 +235,9 @@ const close = () => {
234
235
  }
235
236
  };
236
237
 
237
- const clickOutside = (e: MouseEvent) => {
238
+ const overlayClick = (e: MouseEvent) => {
239
+ emit('click:overlay', e);
240
+
238
241
  if (e.target === pmWrapper.value) {
239
242
  close();
240
243
  }