@avakhula/ui 0.0.104 → 0.0.106

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@avakhula/ui",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
@@ -29,23 +29,23 @@
29
29
  "@babel/core": "^7.20.7",
30
30
  "@babel/preset-env": "^7.21.4",
31
31
  "@rushstack/eslint-patch": "^1.1.4",
32
- "@storybook/addon-a11y": "^7.0.22",
33
- "@storybook/addon-actions": "^7.0.22",
34
- "@storybook/addon-docs": "^7.0.22",
35
- "@storybook/addon-essentials": "^7.0.22",
36
- "@storybook/addon-interactions": "^7.0.22",
37
- "@storybook/addon-links": "^7.0.22",
38
- "@storybook/addon-mdx-gfm": "^7.0.22",
32
+ "@storybook/addon-a11y": "^7.1.0",
33
+ "@storybook/addon-actions": "^7.1.0",
34
+ "@storybook/addon-docs": "^7.1.0",
35
+ "@storybook/addon-essentials": "^7.1.0",
36
+ "@storybook/addon-interactions": "^7.1.0",
37
+ "@storybook/addon-links": "^7.1.0",
38
+ "@storybook/addon-mdx-gfm": "^7.1.0",
39
39
  "@storybook/testing-library": "^0.2.0",
40
- "@storybook/vue3": "^7.0.22",
41
- "@storybook/vue3-vite": "^7.0.22",
40
+ "@storybook/vue3": "^7.1.0",
41
+ "@storybook/vue3-vite": "^7.1.0",
42
42
  "@vitejs/plugin-vue": "^4.0.0",
43
43
  "@vitest/coverage-c8": "^0.28.4",
44
44
  "@vue/eslint-config-prettier": "^7.0.0",
45
45
  "@vue/test-utils": "^2.2.10",
46
46
  "babel-loader": "^8.3.0",
47
47
  "eslint": "^8.22.0",
48
- "eslint-plugin-storybook": "^0.6.12",
48
+ "eslint-plugin-storybook": "^0.6.13",
49
49
  "eslint-plugin-vue": "^9.3.0",
50
50
  "flatpickr": "^4.6.13",
51
51
  "jsdom": "^21.1.0",
@@ -56,7 +56,7 @@
56
56
  "react-dom": "^18.2.0",
57
57
  "sass": "^1.57.1",
58
58
  "sass-loader": "^13.2.0",
59
- "storybook": "^7.0.22",
59
+ "storybook": "^7.1.0",
60
60
  "vite": "^4.0.0",
61
61
  "vitest": "^0.28.4",
62
62
  "vue-loader": "^16.8.3",
@@ -6,6 +6,7 @@
6
6
  <input
7
7
  v-bind="attrs"
8
8
  v-model="actualValue"
9
+ :readonly="readonly"
9
10
  :disabled="disabled"
10
11
  :id="id"
11
12
  :class="classes"
@@ -19,8 +20,9 @@
19
20
  <ib-icon-button
20
21
  kind="ghost"
21
22
  class="button-clear"
22
- @click.prevent="clearInput"
23
+ :disabled="readonly"
23
24
  :help-text="clearButtonMessage"
25
+ @click.prevent="clearInput"
24
26
  v-if="actualValue?.length && type !== 'password' && showClearButton"
25
27
  >
26
28
  <ib-icon name="close-outline"></ib-icon>
@@ -29,6 +31,7 @@
29
31
  <ib-icon-button
30
32
  kind="ghost"
31
33
  class="toggle-password"
34
+ :disabled="readonly"
32
35
  :help-text="showPassword ? hidePasswordMessage : showPasswordMessage"
33
36
  @click.prevent="toggleShowPassword"
34
37
  v-if="actualValue?.length && type === 'password'"
@@ -146,6 +149,10 @@ export default {
146
149
  type: String,
147
150
  default: horizontalPosition.right,
148
151
  },
152
+ readonly: {
153
+ type: Boolean,
154
+ default: false,
155
+ },
149
156
  },
150
157
  data() {
151
158
  return {
@@ -90,7 +90,7 @@ $input-border-error-color: $red-800;
90
90
  color: $input-placeholder-color;
91
91
  }
92
92
 
93
- &:hover {
93
+ &:hover:not(&:read-only) {
94
94
  color: $input-hover-color;
95
95
  background-color: $input-hover-bg;
96
96
  border-bottom-color: $input-hover-border-color;
@@ -93,6 +93,7 @@ $description-color: $gray-700;
93
93
  .head-content {
94
94
  @include Ib-H4-regular;
95
95
  color: $description-color;
96
+ width: 100%;
96
97
  }
97
98
  }
98
99
  }
@@ -16,11 +16,15 @@ export default {
16
16
  type: String,
17
17
  default: popoverPosition.topCenter,
18
18
  },
19
+ alwaysVisible: {
20
+ type: Boolean,
21
+ default: false,
22
+ },
19
23
  },
20
24
  data() {
21
25
  return {
22
26
  parentNode: null,
23
- isVisible: false,
27
+ isVisible: this.alwaysVisible ? true : false,
24
28
  };
25
29
  },
26
30
  mounted() {
@@ -31,10 +35,12 @@ export default {
31
35
  this.parentNode.style.position = "relative";
32
36
  }
33
37
 
34
- this.parentNode.addEventListener("focus", this.showPopover, true);
35
- this.parentNode.addEventListener("blur", this.hidePopover, true);
36
- this.parentNode.addEventListener("mouseover", this.showPopover, true);
37
- this.parentNode.addEventListener("mouseleave", this.hidePopover, true);
38
+ if (!this.alwaysVisible) {
39
+ this.parentNode.addEventListener("focus", this.showPopover, true);
40
+ this.parentNode.addEventListener("blur", this.hidePopover, true);
41
+ this.parentNode.addEventListener("mouseover", this.showPopover, true);
42
+ this.parentNode.addEventListener("mouseleave", this.hidePopover, true);
43
+ }
38
44
  });
39
45
  },
40
46
  methods: {
@@ -58,10 +64,12 @@ export default {
58
64
  },
59
65
  },
60
66
  beforeUnmount() {
61
- this.parentNode.removeEventListener("focus", this.showPopover, true);
62
- this.parentNode.removeEventListener("blur", this.hidePopover, true);
63
- this.parentNode.removeEventListener("mouseover", this.showPopover, true);
64
- this.parentNode.removeEventListener("mouseleave", this.hidePopover, true);
67
+ if (!this.alwaysVisible) {
68
+ this.parentNode.removeEventListener("focus", this.showPopover, true);
69
+ this.parentNode.removeEventListener("blur", this.hidePopover, true);
70
+ this.parentNode.removeEventListener("mouseover", this.showPopover, true);
71
+ this.parentNode.removeEventListener("mouseleave", this.hidePopover, true);
72
+ }
65
73
  },
66
74
  };
67
75
  </script>
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <ib-popover :position="position" :class="classList">
2
+ <ib-popover
3
+ :position="position"
4
+ :always-visible="alwaysVisible"
5
+ :class="classList"
6
+ >
3
7
  <b v-if="title">{{ title }}</b>
4
8
  <p>{{ text }}</p>
5
9
  </ib-popover>
@@ -20,6 +24,10 @@ export default {
20
24
  text: {
21
25
  type: String,
22
26
  },
27
+ alwaysVisible: {
28
+ type: Boolean,
29
+ default: false,
30
+ },
23
31
  },
24
32
  computed: {
25
33
  classList() {
@@ -46,6 +54,17 @@ export default {
46
54
  max-width: 240px;
47
55
  box-shadow: $ib-shadow-1;
48
56
 
57
+ &::after {
58
+ content: "";
59
+ width: 100%;
60
+ height: calc(100% + 5px);
61
+ position: absolute;
62
+ left: 0;
63
+ right: 0;
64
+ bottom: -5px;
65
+ z-index: -1;
66
+ }
67
+
49
68
  &.ib-tooltip-large {
50
69
  box-shadow: $ib-shadow-2;
51
70
  }
@@ -7,22 +7,35 @@ export default class Tooltip {
7
7
  this.tooltipContainer = null;
8
8
  }
9
9
 
10
+ getTooltipInstance() {
11
+ return this.getTooltipInstance;
12
+ }
13
+
14
+ getTooltipContainer() {
15
+ return this.tooltipContainer;
16
+ }
17
+
10
18
  createTooltip(el, text) {
19
+ if (!text.trim().length) {
20
+ return;
21
+ }
22
+
11
23
  const tooltipContainerStyles = `
12
24
  position: absolute;
13
25
  top: 0px;
14
26
  left: 0px;
15
27
  `;
28
+
16
29
  this.tooltipContainer = document.createElement("div");
17
30
  this.tooltipContainer.setAttribute("style", tooltipContainerStyles);
18
31
 
19
32
  document.body.appendChild(this.tooltipContainer);
20
33
  this.tooltipInstance = createApp(IbTooltip, {
21
34
  text: text,
35
+ alwaysVisible: true,
22
36
  });
23
37
 
24
38
  this.tooltipInstance.mount(this.tooltipContainer);
25
- this.tooltipContainer.firstChild.setAttribute("style", "display: block");
26
39
 
27
40
  setTimeout(() => {
28
41
  if (this.tooltipContainer?.firstChild) {
@@ -45,11 +58,9 @@ export default class Tooltip {
45
58
  }
46
59
 
47
60
  destroyTooltip() {
48
- if (this.tooltipInstance && this.tooltipContainer) {
49
- this.tooltipInstance.unmount();
50
- this.tooltipInstance = null;
51
- this.tooltipContainer.remove();
52
- this.tooltipContainer = null;
53
- }
61
+ this.tooltipInstance?.unmount();
62
+ this.tooltipInstance = null;
63
+ this.tooltipContainer?.remove();
64
+ this.tooltipContainer = null;
54
65
  }
55
66
  }
@@ -2,22 +2,33 @@ import Tooltip from "./TooltipController";
2
2
 
3
3
  const tooltip = new Tooltip();
4
4
  const createTooltip = (el, binding) => {
5
- tooltip.createTooltip(el, binding.value);
5
+ if (!tooltip.getTooltipContainer()) {
6
+ tooltip.createTooltip(el, binding.value);
7
+ }
6
8
  };
7
9
 
8
- const destroyTooltip = () => {
9
- tooltip.destroyTooltip();
10
+ const destroyTooltip = (event, el) => {
11
+ const tooltipContainer = tooltip.getTooltipContainer();
12
+
13
+ const isMouseOverEl = el !== event.target && !el.contains(event.target);
14
+ const isMouseOverTooltip =
15
+ tooltipContainer !== event.target &&
16
+ !tooltipContainer?.contains(event.target);
17
+
18
+ if (isMouseOverEl && isMouseOverTooltip) {
19
+ tooltip.destroyTooltip();
20
+ }
10
21
  };
11
22
 
12
23
  export const TooltipDirective = {
13
24
  mounted(el, binding) {
14
25
  el.addEventListener("mouseenter", () => createTooltip(el, binding));
15
- el.addEventListener("mouseleave", destroyTooltip);
26
+ document.addEventListener("mousemove", (e) => destroyTooltip(e, el));
16
27
  },
17
28
 
18
29
  beforeUnmount(el, binding) {
19
30
  tooltip.destroyTooltip();
20
31
  el.removeEventListener("mouseenter", () => createTooltip(el, binding));
21
- el.removeEventListener("mouseleave", destroyTooltip);
32
+ document.removeEventListener("mousemove", (e) => destroyTooltip(e, el));
22
33
  },
23
34
  };