@signal24/vue-foundation 4.15.0 → 4.16.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.15.0",
4
+ "version": "4.16.0",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "uuid": "^9.0.1"
37
+ "uuid": "^10.0.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@signal24/openapi-client-codegen": "^1.1.0",
@@ -43,37 +43,37 @@
43
43
  "vue": "^3.4.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@nabla/vite-plugin-eslint": "^2.0.2",
47
- "@rushstack/eslint-patch": "^1.6.1",
46
+ "@nabla/vite-plugin-eslint": "^2.0.4",
47
+ "@rushstack/eslint-patch": "^1.10.4",
48
48
  "@signal24/openapi-client-codegen": "^1.1.0",
49
- "@tsconfig/node20": "^20.1.2",
50
- "@types/jsdom": "^21.1.6",
51
- "@types/lodash": "^4.14.202",
52
- "@types/node": "^20.10.5",
53
- "@types/uuid": "^9.0.7",
54
- "@vitejs/plugin-vue": "^5.0.0",
49
+ "@tsconfig/node20": "^20.1.4",
50
+ "@types/jsdom": "^21.1.7",
51
+ "@types/lodash": "^4.17.7",
52
+ "@types/node": "^20.16.3",
53
+ "@types/uuid": "^10.0.0",
54
+ "@vitejs/plugin-vue": "^5.1.3",
55
55
  "@vue/eslint-config-prettier": "^9.0.0",
56
56
  "@vue/eslint-config-typescript": "^13.0.0",
57
- "@vue/test-utils": "^2.4.3",
57
+ "@vue/test-utils": "^2.4.6",
58
58
  "@vue/tsconfig": "^0.5.1",
59
- "cypress": "^13.6.2",
60
- "date-fns": "^3.0.6",
61
- "eslint": "^8.56.0",
62
- "eslint-plugin-cypress": "^3.3.0",
63
- "eslint-plugin-simple-import-sort": "^12.1.0",
64
- "eslint-plugin-unused-imports": "^4.0.0",
65
- "eslint-plugin-vue": "^9.19.2",
66
- "jsdom": "^23.0.1",
59
+ "cypress": "^13.14.1",
60
+ "date-fns": "^3.6.0",
61
+ "eslint": "^8.57.0",
62
+ "eslint-plugin-cypress": "^3.5.0",
63
+ "eslint-plugin-simple-import-sort": "^12.1.1",
64
+ "eslint-plugin-unused-imports": "^4.1.3",
65
+ "eslint-plugin-vue": "^9.28.0",
66
+ "jsdom": "^25.0.0",
67
67
  "lodash": "^4.17.21",
68
- "prettier": "^3.1.1",
69
- "sass": "^1.69.6",
70
- "start-server-and-test": "^2.0.3",
71
- "type-fest": "^4.9.0",
72
- "typescript": "~5.3.3",
73
- "vite": "^5.0.10",
74
- "vitest": "^1.1.0",
75
- "vue": "^3.4.0",
76
- "vue-tsc": "^1.8.27"
68
+ "prettier": "^3.3.3",
69
+ "sass": "^1.77.8",
70
+ "start-server-and-test": "^2.0.5",
71
+ "type-fest": "^4.26.0",
72
+ "typescript": "~5.5.4",
73
+ "vite": "^5.4.3",
74
+ "vitest": "^2.0.5",
75
+ "vue": "^3.5.0",
76
+ "vue-tsc": "^2.1.4"
77
77
  },
78
78
  "packageManager": "yarn@4.0.2"
79
79
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Modal class="vf-alert" :class="classes">
2
+ <Modal :class="['vf-alert', ...(classes ?? [])]">
3
3
  <template v-if="title" v-slot:header>
4
4
  <h1>{{ title }}</h1>
5
5
  </template>
@@ -46,6 +46,6 @@ watch(
46
46
  }
47
47
  );
48
48
  watch(selectedItem, value => {
49
- emit('update:modelValue', value ? computedOpts.value.find(o => isEqual(o, value))?.value ?? null : null);
49
+ emit('update:modelValue', value ? (computedOpts.value.find(o => isEqual(o, value))?.value ?? null) : null);
50
50
  });
51
51
  </script>
@@ -29,7 +29,7 @@ const props = defineProps<{
29
29
  closeOnMaskClick?: boolean;
30
30
  scrolls?: boolean;
31
31
  closeX?: boolean;
32
- class?: string;
32
+ class?: string | string[];
33
33
  }>();
34
34
 
35
35
  defineEmits(['formSubmit']);
@@ -41,7 +41,7 @@ const form = ref<HTMLFormElement>();
41
41
  const isHidden = ref(false);
42
42
 
43
43
  const classList = computed(() => {
44
- return compact([props.class, isHidden.value && 'hidden']);
44
+ return compact([...(Array.isArray(props.class) ? props.class : [props.class]), isHidden.value && 'hidden']);
45
45
  });
46
46
 
47
47
  onMounted(() => {
@@ -0,0 +1,51 @@
1
+ import { last } from 'lodash';
2
+ import type { DirectiveBinding, ObjectDirective } from 'vue';
3
+
4
+ export const vHotkey: ObjectDirective<HTMLButtonElement, string> = {
5
+ mounted: setup,
6
+ updated: reset,
7
+ unmounted: teardown
8
+ };
9
+
10
+ const ElementsByHotkey = new Map<string, HTMLButtonElement[]>();
11
+
12
+ function setup(el: HTMLButtonElement, binding: DirectiveBinding<string>) {
13
+ if (ElementsByHotkey.size === 0) {
14
+ window.addEventListener('keydown', handleKeydown);
15
+ }
16
+
17
+ ElementsByHotkey.set(binding.value.toLowerCase(), [...(ElementsByHotkey.get(binding.value.toLowerCase()) ?? []), el]);
18
+ }
19
+
20
+ function teardown(el: HTMLButtonElement, binding: DirectiveBinding<string>) {
21
+ const elements = ElementsByHotkey.get(binding.value.toLowerCase());
22
+ if (elements) {
23
+ const index = elements.indexOf(el);
24
+ if (index !== -1) {
25
+ elements.splice(index, 1);
26
+ }
27
+
28
+ if (elements.length === 0) {
29
+ ElementsByHotkey.delete(binding.value.toLowerCase());
30
+ }
31
+ }
32
+
33
+ if (ElementsByHotkey.size === 0) {
34
+ window.removeEventListener('keydown', handleKeydown);
35
+ }
36
+ }
37
+
38
+ function reset(el: HTMLButtonElement, binding: DirectiveBinding<string>) {
39
+ teardown(el, binding);
40
+ setup(el, binding);
41
+ }
42
+
43
+ function handleKeydown(event: KeyboardEvent) {
44
+ const hotkey = event.key.toLowerCase();
45
+ const elements = ElementsByHotkey.get(hotkey);
46
+ if (elements) {
47
+ const element = last(elements);
48
+ element?.click();
49
+ event.preventDefault();
50
+ }
51
+ }
@@ -6,6 +6,7 @@ import { vDateInput } from './date-input';
6
6
  import { vDatetime } from './datetime';
7
7
  import { vDisabled } from './disabled';
8
8
  import { vDuration } from './duration';
9
+ import { vHotkey } from './hotkey';
9
10
  import { vInfiniteScroll } from './infinite-scroll';
10
11
  import { vReadonly } from './readonly';
11
12
  import { vTooltip } from './tooltip';
@@ -18,6 +19,7 @@ declare module 'vue' {
18
19
  vDatetime: typeof vDatetime;
19
20
  vDisabled: typeof vDisabled;
20
21
  vDuration: typeof vDuration;
22
+ vHotkey: typeof vHotkey;
21
23
  vInfiniteScroll: typeof vInfiniteScroll;
22
24
  vReadonly: typeof vReadonly;
23
25
  vTooltip: typeof vTooltip;
@@ -31,6 +33,7 @@ export function registerDirectives(app: App<Element>): void {
31
33
  app.directive('datetime', vDatetime);
32
34
  app.directive('disabled', vDisabled);
33
35
  app.directive('duration', vDuration);
36
+ app.directive('hotkey', vHotkey);
34
37
  app.directive('infinite-scroll', vInfiniteScroll);
35
38
  app.directive('readonly', vReadonly);
36
39
  app.directive('tooltip', vTooltip);
@@ -47,6 +47,8 @@ interface ITooltipOptions {
47
47
  class?: string | string[];
48
48
  }
49
49
 
50
+ // todo: improve with mutation observer to see removal of node
51
+
50
52
  class VfTooltip {
51
53
  private lastMoveEvt?: MouseEvent;
52
54
  private checkInterval?: ReturnType<typeof setInterval>;
@@ -66,6 +68,7 @@ class VfTooltip {
66
68
  ) {
67
69
  el.addEventListener('mouseenter', this.handleTargetMouseEnterWithContext);
68
70
  el.addEventListener('mouseleave', this.handleTargetMouseLeaveWithContext);
71
+ el.addEventListener('click', this.handleTargetMouseLeaveWithContext);
69
72
  }
70
73
 
71
74
  configure(config: ITooltipOptions) {
@@ -189,5 +192,6 @@ class VfTooltip {
189
192
 
190
193
  this.el.removeEventListener('mouseenter', this.handleTargetMouseEnterWithContext);
191
194
  this.el.removeEventListener('mouseleave', this.handleTargetMouseLeaveWithContext);
195
+ this.el.removeEventListener('click', this.handleTargetMouseLeaveWithContext);
192
196
  }
193
197
  }