@signal24/vue-foundation 4.30.3 → 4.30.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.30.3",
4
+ "version": "4.30.4",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -6,6 +6,7 @@ interface IAlertOptions {
6
6
  message: string | Error;
7
7
  classes?: string[];
8
8
  iconClass?: string | string[];
9
+ isHtml?: boolean;
9
10
  }
10
11
 
11
12
  function resolveAlertParams(arg0: string | Error | IAlertOptions, arg1?: string | Error) {
@@ -6,8 +6,8 @@
6
6
 
7
7
  <i v-if="iconClass" :class="['vf-alert-icon', iconClass]" />
8
8
 
9
- <div v-if="isHtml" :innerHtml="message" class="user-message"></div>
10
- <div v-else :innerText="textMessage"></div>
9
+ <div v-if="isHtml" :innerHTML="resolvedMessage" class="user-message"></div>
10
+ <div v-else :innerText="resolvedMessage"></div>
11
11
 
12
12
  <template v-if="!isBare" #footer>
13
13
  <template v-if="shouldConfirm">
@@ -36,7 +36,7 @@ const props = defineProps<{
36
36
  callback: (ok: boolean) => void;
37
37
  }>();
38
38
 
39
- const textMessage = computed(() => {
39
+ const resolvedMessage = computed(() => {
40
40
  if (props.message instanceof Error) {
41
41
  return formatError(props.message);
42
42
  }
package/src/config.ts CHANGED
@@ -5,6 +5,7 @@ interface IOptions {
5
5
  defaultTimeFormat: string;
6
6
  defaultCurrencyDivisor: number;
7
7
  onOverlaysChanged?: (count: number) => void;
8
+ disableStickyMinWidthDirective?: boolean;
8
9
  }
9
10
 
10
11
  export const VfOptions: IOptions = {
@@ -1,24 +1,45 @@
1
1
  import type { ObjectDirective } from 'vue';
2
2
 
3
+ import { VfOptions } from '@/config';
4
+
3
5
  const ObserverMap = new WeakMap<HTMLElement, ResizeObserver>();
4
6
 
5
- export const vStickyMinWidth: ObjectDirective<HTMLElement> = {
6
- beforeMount(el) {
7
- const observer = new ResizeObserver(() => {
8
- const computedMinWidthStr = window.getComputedStyle(el).minWidth.match(/^(\d+)px$/)?.[1];
9
- const computedMinWidth = computedMinWidthStr ? parseInt(computedMinWidthStr, 10) : 0;
10
- if (el.clientWidth <= computedMinWidth) return;
11
- el.style.minWidth = `${el.clientWidth}px`;
12
- });
13
- ObserverMap.set(el, observer);
14
- observer.observe(el);
7
+ export const vStickyMinWidth: ObjectDirective<HTMLElement, boolean | undefined> = {
8
+ beforeMount(el, binding) {
9
+ if (binding.value === false || VfOptions.disableStickyMinWidthDirective) return;
10
+ setup(el);
15
11
  },
16
12
 
17
- beforeUnmount(el) {
18
- const observer = ObserverMap.get(el);
19
- if (observer) {
20
- observer.unobserve(el);
21
- ObserverMap.delete(el);
13
+ updated(el, binding) {
14
+ if (binding.value !== binding.oldValue) {
15
+ if (binding.value === false || VfOptions.disableStickyMinWidthDirective) {
16
+ teardown(el);
17
+ } else {
18
+ setup(el);
19
+ }
22
20
  }
21
+ },
22
+
23
+ beforeUnmount(el) {
24
+ teardown(el);
23
25
  }
24
26
  };
27
+
28
+ function setup(el: HTMLElement) {
29
+ const observer = new ResizeObserver(() => {
30
+ const computedMinWidthStr = window.getComputedStyle(el).minWidth.match(/^(\d+)px$/)?.[1];
31
+ const computedMinWidth = computedMinWidthStr ? parseInt(computedMinWidthStr, 10) : 0;
32
+ if (el.clientWidth <= computedMinWidth) return;
33
+ el.style.minWidth = `${el.clientWidth}px`;
34
+ });
35
+ ObserverMap.set(el, observer);
36
+ observer.observe(el);
37
+ }
38
+
39
+ function teardown(el: HTMLElement) {
40
+ const observer = ObserverMap.get(el);
41
+ if (observer) {
42
+ observer.unobserve(el);
43
+ ObserverMap.delete(el);
44
+ }
45
+ }
@@ -1,5 +1,7 @@
1
1
  import type { DirectiveBinding, ObjectDirective } from 'vue';
2
2
 
3
+ import { showAlert } from '@/components';
4
+
3
5
  type TooltipValue = string | null | false | undefined;
4
6
 
5
7
  export const vTooltip: ObjectDirective<TooltipElement, TooltipValue> = {
@@ -21,7 +23,8 @@ function createTip(el: TooltipElement, binding: DirectiveBinding<TooltipValue>)
21
23
  if (tipText) {
22
24
  const config: ITooltipOptions = {
23
25
  content: tipText,
24
- html: el.getAttribute('html') !== null
26
+ html: el.getAttribute('html') !== null,
27
+ alertOnTap: el.getAttribute('alert-on-tap') !== null
25
28
  };
26
29
 
27
30
  if (!el[TooltipState]) {
@@ -45,6 +48,7 @@ interface ITooltipOptions {
45
48
  delay?: number;
46
49
  html?: boolean;
47
50
  class?: string | string[];
51
+ alertOnTap?: boolean;
48
52
  }
49
53
 
50
54
  // todo: improve with mutation observer to see removal of node
@@ -69,6 +73,7 @@ class VfTooltip {
69
73
  el.addEventListener('mouseenter', this.handleTargetMouseEnterWithContext);
70
74
  el.addEventListener('mouseleave', this.handleTargetMouseLeaveWithContext);
71
75
  el.addEventListener('click', this.handleTargetMouseLeaveWithContext);
76
+ if (config.alertOnTap) el.addEventListener('touchstart', () => this.showTapAlert());
72
77
  }
73
78
 
74
79
  configure(config: ITooltipOptions) {
@@ -93,6 +98,14 @@ class VfTooltip {
93
98
  if (e) this.handleMouseMove(e);
94
99
  }
95
100
 
101
+ showTapAlert() {
102
+ showAlert({
103
+ title: this.config.title,
104
+ message: this.config.content,
105
+ isHtml: this.config.html ?? false
106
+ });
107
+ }
108
+
96
109
  renderTooltip() {
97
110
  if (!this.tipEl) {
98
111
  this.tipEl = document.createElement('div');