@avakhula/ui 0.0.213 → 0.0.215

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.213",
3
+ "version": "0.0.215",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
@@ -29,16 +29,16 @@
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.3.2",
33
- "@storybook/addon-actions": "^7.3.2",
34
- "@storybook/addon-docs": "^7.3.2",
35
- "@storybook/addon-essentials": "^7.3.2",
36
- "@storybook/addon-interactions": "^7.3.2",
37
- "@storybook/addon-links": "^7.3.2",
38
- "@storybook/addon-mdx-gfm": "^7.3.2",
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.3.2",
41
- "@storybook/vue3-vite": "^7.3.2",
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",
@@ -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.3.2",
59
+ "storybook": "^7.1.0",
60
60
  "vite": "^4.0.0",
61
61
  "vitest": "^0.28.4",
62
62
  "vue-loader": "^16.8.3",
@@ -76,10 +76,13 @@ $content-bg: $gray-50;
76
76
  .accordion-content {
77
77
  border-radius: 0 0 4px 4px;
78
78
  border: 1px solid $content-border-color;
79
- padding:10px 15px 15px;
80
79
  overflow: hidden;
81
80
  transition: height 0.3s, padding-top 0.3s, padding-bottom 0.3s;
82
81
  background-color: $content-bg;
82
+
83
+ .accordion-content-wrapper {
84
+ padding: 10px 15px 15px;
85
+ }
83
86
  }
84
87
 
85
88
  &.active {
@@ -25,7 +25,9 @@
25
25
  :id="'accordion-section-' + uuid"
26
26
  :aria-labelledby="'accordion' + uuid"
27
27
  >
28
- <slot name="content"></slot>
28
+ <div class="accordion-content-wrapper">
29
+ <slot name="content"></slot>
30
+ </div>
29
31
  </div>
30
32
  </Transition>
31
33
  </div>
@@ -147,6 +147,7 @@ $alert-success-secondary-color: $green-50;
147
147
  margin-right: 5px;
148
148
  }
149
149
 
150
+ &-error,
150
151
  &-alert {
151
152
  border-left-color: $alert-alert-primary-color;
152
153
  background-color: $alert-alert-secondary-color;
@@ -1,5 +1,6 @@
1
1
  export const alertTypeOptions = {
2
2
  alert: "alert",
3
+ error: "error",
3
4
  warning: "warning",
4
5
  info: "info",
5
6
  success: "success",
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <img v-if="src && !userAvatar" :class="classList" :src="src" :alt="name" />
2
+ <img
3
+ v-if="src && !userAvatar"
4
+ :class="classList"
5
+ :src="src"
6
+ :alt="firstName + '' + lastName"
7
+ />
3
8
 
4
9
  <div
5
10
  v-else-if="src && userAvatar"
@@ -10,7 +15,7 @@
10
15
  }"
11
16
  ></div>
12
17
 
13
- <div v-else-if="validateName" class="empty-avatar" :class="classList">
18
+ <div v-else-if="!validateName" class="empty-avatar" :class="classList">
14
19
  <ib-icon name="camera-outline" />
15
20
  </div>
16
21
 
@@ -26,7 +31,11 @@ import { avatarSizes } from "./constants";
26
31
  export default {
27
32
  name: "IbAvatar",
28
33
  props: {
29
- name: {
34
+ firstName: {
35
+ type: String,
36
+ default: "",
37
+ },
38
+ lastName: {
30
39
  type: String,
31
40
  default: "",
32
41
  },
@@ -49,14 +58,13 @@ export default {
49
58
  return classList;
50
59
  },
51
60
  validateName() {
52
- return this.name?.trim().split(" ").length < 2;
61
+ return (
62
+ this.firstName?.trim().length !== 0 &&
63
+ this.lastName?.trim().length !== 0
64
+ );
53
65
  },
54
66
  initials() {
55
- const words = this.name.split(" ");
56
-
57
- return words.length === 1
58
- ? (words[0][0] + words[0][1]).toUpperCase()
59
- : (words[0][0] + words[1][0]).toUpperCase();
67
+ return this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
60
68
  },
61
69
  },
62
70
  components: {
@@ -250,6 +250,9 @@ export default {
250
250
  value(newVal) {
251
251
  this.actualValue = newVal;
252
252
  },
253
+ modelValue(newVal) {
254
+ this.actualValue = newVal;
255
+ },
253
256
  disabled(newVal) {
254
257
  this.$globalEvents.$emit(`label:disabled:${this.id}`, newVal);
255
258
  },
@@ -16,7 +16,7 @@ export default {
16
16
  },
17
17
  tooltipPosition: {
18
18
  control: { type: "select" },
19
- options: Object.values(popoverPosition),
19
+ options: Object.keys(popoverPosition),
20
20
  },
21
21
  },
22
22
  };
@@ -8,32 +8,46 @@
8
8
  }"
9
9
  v-if="view === sortingTypesView.TABLE_VIEW"
10
10
  >
11
- <button class="sorting-label" type="button">
12
- {{ title }}
13
- <ib-tooltip
14
- v-if="tooltipText"
15
- :text="tooltipText"
16
- :position="tooltipPosition"
11
+ <div>
12
+ <button
13
+ v-tooltip:[tooltipPosition]="tooltipText"
14
+ class="sorting-label"
15
+ type="button"
16
+ @click="isOpenToggleTip = true"
17
17
  >
18
- </ib-tooltip>
19
- </button>
20
- <ib-icon-button kind="white" size="s" @click="clickHandler">
21
- <ion-icon :name="iconType"></ion-icon>
22
- <ib-tooltip
23
- v-if="tooltipIconSorting"
24
- :text="tooltipIconSorting"
25
- :position="tooltipPosition"
18
+ {{ title }}
19
+ </button>
20
+
21
+ <ib-toggle-tip
22
+ v-if="hasToggleTip"
23
+ :is-open="isOpenToggleTip"
24
+ :title="toggleTipTitle"
25
+ @close="isOpenToggleTip = false"
26
26
  >
27
- </ib-tooltip>
27
+ <slot name="toggleTipBody"></slot>
28
+ <template #buttons>
29
+ <slot name="toggleTipButtons"></slot>
30
+ </template>
31
+ </ib-toggle-tip>
32
+ </div>
33
+
34
+ <ib-icon-button
35
+ v-tooltip="tooltipIconText"
36
+ kind="white"
37
+ size="s"
38
+ @click="clickHandler"
39
+ >
40
+ <ion-icon :name="iconType"></ion-icon>
28
41
  </ib-icon-button>
29
42
  </div>
30
43
 
31
44
  <button
32
45
  v-else
46
+ v-tooltip:[tooltipPosition]="tooltipText"
33
47
  class="sorting-button"
34
48
  type="button"
35
- :aria-label="sort"
36
49
  @click="clickHandler"
50
+ :aria-label="sort"
37
51
  :class="{
38
52
  active: currentTypeSort,
39
53
  disabled: disable,
@@ -41,12 +55,6 @@
41
55
  >
42
56
  {{ title }}
43
57
  <ib-icon v-if="iconType" :name="iconType"></ib-icon>
44
- <ib-tooltip
45
- v-if="tooltipText"
46
- :text="tooltipText"
47
- :position="tooltipPosition"
48
- >
49
- </ib-tooltip>
50
58
  </button>
51
59
  </div>
52
60
  </template>
@@ -54,9 +62,9 @@
54
62
  <script>
55
63
  import IbIcon from "../Icon.vue";
56
64
  import IbIconButton from "../IconButton/IconButton.vue";
57
- import IbTooltip from "../Tooltip/Tooltip.vue";
65
+ import IbToggleTip from "../ToggleTip/ToggleTip.vue";
58
66
  import { typesSorting, typesSortingView } from "./constants.js";
59
-
67
+ import { TooltipDirective as Tooltip } from "../../directives/tooltip/tooltip";
60
68
  export default {
61
69
  name: "IbSorting",
62
70
  props: {
@@ -69,6 +77,9 @@ export default {
69
77
  tooltipIconSorting: {
70
78
  type: String,
71
79
  },
80
+ toggleTipTitle: {
81
+ type: String,
82
+ },
72
83
  title: {
73
84
  type: String,
74
85
  default: "",
@@ -99,6 +110,7 @@ export default {
99
110
  },
100
111
  data() {
101
112
  return {
113
+ isOpenToggleTip: false,
102
114
  sortingTypes: typesSorting,
103
115
  sortingTypesView: typesSortingView,
104
116
  currentTypeSort: this.sort,
@@ -132,11 +144,29 @@ export default {
132
144
  }
133
145
  return null;
134
146
  },
147
+ tooltipIconText() {
148
+ if (this.currentTypeSort === this.sortingTypes.TYPE_ASC) {
149
+ return lang("sort_descending", this.langComponents?.COMPONENT_SELECT);
150
+ } else if (this.currentTypeSort === this.sortingTypes.TYPE_DESC) {
151
+ return lang("reset_sorting", this.langComponents?.COMPONENT_SELECT);
152
+ } else if (this.view !== this.sortingTypesView.GRID_VIEW) {
153
+ return lang("sort_ascending", this.langComponents?.COMPONENT_SELECT);
154
+ }
155
+ return "";
156
+ },
157
+ hasToggleTip() {
158
+ return (
159
+ this.toggleTipTitle &&
160
+ this.$slots.toggleTipBody &&
161
+ this.$slots.toggleTipButtons
162
+ );
163
+ },
135
164
  },
165
+ directives: { Tooltip },
136
166
  components: {
137
167
  IbIcon,
138
168
  IbIconButton,
139
- IbTooltip,
169
+ IbToggleTip,
140
170
  },
141
171
  };
142
172
  </script>
@@ -22,7 +22,7 @@ button {
22
22
 
23
23
  .sorting-label {
24
24
  border: solid 2px transparent;
25
- padding: 0 4px;
25
+ padding: 0 2px;
26
26
  border-radius: 4px;
27
27
  margin-right: 2px;
28
28
  @include Ib-H4-medium;
@@ -53,17 +53,7 @@ export default {
53
53
  padding: 10px;
54
54
  max-width: 240px;
55
55
  box-shadow: $ib-shadow-1;
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
- }
56
+ z-index: 9999;
67
57
 
68
58
  &.ib-tooltip-large {
69
59
  box-shadow: $ib-shadow-2;
@@ -76,5 +66,99 @@ export default {
76
66
  p {
77
67
  @include Ib-H4-regular;
78
68
  }
69
+
70
+ &::before {
71
+ content: "";
72
+ width: 0;
73
+ height: 0;
74
+ border-style: solid;
75
+ border-width: 4px 4px 0 4px;
76
+ border-color: #fff transparent transparent transparent;
77
+ position: absolute;
78
+ transform: none !important;
79
+ }
80
+
81
+ &.top-left {
82
+ &::before {
83
+ bottom: -4px;
84
+ right: 10px;
85
+ }
86
+ }
87
+ &.top-center {
88
+ &::before {
89
+ bottom: -4px;
90
+ right: 50%;
91
+ transform: translateX(50%) !important;
92
+ }
93
+ }
94
+ &.top-right {
95
+ &::before {
96
+ bottom: -4px;
97
+ left: 10px;
98
+ }
99
+ }
100
+ &.right-top {
101
+ &::before {
102
+ left: -6px;
103
+ bottom: 10px;
104
+ transform: rotate(90deg) !important;
105
+ }
106
+ }
107
+ &.right-center {
108
+ &::before {
109
+ left: -8px;
110
+ top: 50%;
111
+ transform: rotate(90deg) translateY(-50%) !important;
112
+ }
113
+ }
114
+ &.right-bottom {
115
+ &::before {
116
+ top: 10px;
117
+ left: -6px;
118
+ transform: rotate(90deg) !important;
119
+ }
120
+ }
121
+ &.bottom-left {
122
+ &::before {
123
+ top: -4px;
124
+ right: 10px;
125
+ transform: rotate(180deg) !important;
126
+ }
127
+ }
128
+ &.bottom-center {
129
+ &::before {
130
+ top: -4px;
131
+ right: 50%;
132
+ transform: rotate(180deg) translateX(-50%) !important;
133
+ }
134
+ }
135
+ &.bottom-right {
136
+ &::before {
137
+ top: -4px;
138
+ left: 10px;
139
+ transform: rotate(180deg) !important;
140
+ }
141
+ }
142
+ &.left-top {
143
+ &::before {
144
+ right: -6px;
145
+ bottom: 10px;
146
+ transform: rotate(-90deg) !important;
147
+ }
148
+ }
149
+ &.left-center {
150
+ &::before {
151
+ right: -8px;
152
+ top: 50%;
153
+ transform: rotate(-90deg) translateY(-50%) !important;
154
+ }
155
+ }
156
+ &.left-bottom {
157
+ &::before {
158
+ top: 10px;
159
+ right: -6px;
160
+ transform: rotate(-90deg) !important;
161
+ }
162
+ }
79
163
  }
80
164
  </style>
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <li>
3
3
  <div
4
+ v-tooltip="showTooltip ? option.title : ''"
4
5
  class="tree-select-option"
5
6
  tabindex="0"
6
7
  role="option"
@@ -18,8 +19,6 @@
18
19
  @keydown.self="onKeydown"
19
20
  @focus="$emit('onFocus', `option-${id}`)"
20
21
  >
21
- <ib-tooltip v-if="showTooltip" :text="option.title"></ib-tooltip>
22
-
23
22
  <ib-icon-button
24
23
  :disabled-focus="true"
25
24
  kind="ghost"
@@ -117,7 +116,7 @@ import Toggle from "../Form/Toggle/Toggle.vue";
117
116
  import List from "../List.vue";
118
117
  import IbIcon from "../Icon.vue";
119
118
  import IbIconButton from "../IconButton/IconButton.vue";
120
- import IbTooltip from "../Tooltip/Tooltip.vue";
119
+ import { TooltipDirective as Tooltip } from "../../directives/tooltip/tooltip";
121
120
  import multiLineOverflows from "../../helpers/multiLineOverflows";
122
121
  import {
123
122
  SPACE_KEY_CODE,
@@ -329,8 +328,8 @@ export default {
329
328
  IbIcon,
330
329
  List,
331
330
  IbIconButton,
332
- IbTooltip,
333
331
  },
332
+ directives: { Tooltip },
334
333
  };
335
334
  </script>
336
335
  <style lang="scss">
@@ -26,7 +26,6 @@
26
26
  @blur="onBlur"
27
27
  @keyup.down="comboboxKeyupDown"
28
28
  @keyup.up="comboboxKeyupDown"
29
- :id="id"
30
29
  :aria-label="ariaLabel"
31
30
  :aria-activedescendant="focusedOptionId"
32
31
  :class="{
@@ -68,12 +67,7 @@
68
67
  <div
69
68
  class="tree-drop"
70
69
  :class="{ 'not-tree-child': !hasTreeChildren }"
71
- :style="{
72
- width: 'auto',
73
- position: 'absolute',
74
- left: -size.left + 'px',
75
- right: -size.right + 'px',
76
- }"
70
+ :style="treeDropPos"
77
71
  >
78
72
  <div
79
73
  v-if="isResizable"
@@ -280,6 +274,9 @@ export default {
280
274
  type: Boolean,
281
275
  default: false,
282
276
  },
277
+ menuSize: {
278
+ type: [String, Number],
279
+ },
283
280
  initialSize: {
284
281
  left: 0,
285
282
  right: 0,
@@ -905,6 +902,22 @@ export default {
905
902
  hasEmptyMessage() {
906
903
  return !!this.$slots.emptyMessage;
907
904
  },
905
+ treeDropPos() {
906
+ if (this.menuSize) {
907
+ return {
908
+ width: this.menuSize + "px",
909
+ maxWidth: this.menuSize + "px",
910
+ minWidth: this.menuSize + "px",
911
+ };
912
+ }
913
+
914
+ return {
915
+ width: "auto",
916
+ position: "absolute",
917
+ left: -this.size.left + "px",
918
+ right: -this.size.right + "px",
919
+ };
920
+ },
908
921
  hasHierarchy() {
909
922
  return this.actualOptions.some((option) => {
910
923
  return option.children;
@@ -199,6 +199,10 @@ $option-checked-hover-bg: $blue-50;
199
199
  &.toggle-on {
200
200
  background-color: transparent;
201
201
  }
202
+
203
+ & + .option-label {
204
+ width: calc(100% - 65px);
205
+ }
202
206
  }
203
207
  }
204
208
  }
@@ -1,4 +1,5 @@
1
1
  import { createApp } from "vue";
2
+ import { popoverPosition } from "../../components/Popover/constants";
2
3
  import IbTooltip from "../../components/Tooltip/Tooltip.vue";
3
4
  import generateUID from "../../helpers/generateUID";
4
5
 
@@ -25,8 +26,8 @@ export default class Tooltip {
25
26
  this.uuid = "tooltip_" + generateUID();
26
27
  }
27
28
 
28
- createTooltip(el, text) {
29
- if (!text.length) {
29
+ createTooltip(el, text, position) {
30
+ if (!text?.length) {
30
31
  return;
31
32
  }
32
33
 
@@ -46,6 +47,7 @@ export default class Tooltip {
46
47
  text: text,
47
48
  alwaysVisible: true,
48
49
  for: this.uuid,
50
+ class: this.getClassList(position),
49
51
  });
50
52
 
51
53
  this.tooltipInstance.mount(this.tooltipContainer);
@@ -53,19 +55,8 @@ export default class Tooltip {
53
55
  setTimeout(() => {
54
56
  if (this.tooltipContainer?.firstChild) {
55
57
  el.setAttribute("aria-describedby", this.uuid);
56
- const { top, left, width } = el.getBoundingClientRect();
57
- const { width: tooltipWidth, height: tooltipHeight } =
58
- this.tooltipContainer.firstChild.getBoundingClientRect();
59
- const scrollTop = document.documentElement.scrollTop;
60
-
61
- const tooltipStyles = `
62
- left: ${left + width / 2 - tooltipWidth / 2}px!important;
63
- top: ${top - tooltipHeight + scrollTop - 5}px!important;
64
- bottom: auto!important;
65
- right: auto!important;
66
- transform: none!important;
67
- `;
68
58
 
59
+ const tooltipStyles = this.getPositionStyle(el, position);
69
60
  this.tooltipContainer.firstChild.setAttribute("style", tooltipStyles);
70
61
  }
71
62
  }, 100);
@@ -79,4 +70,112 @@ export default class Tooltip {
79
70
  this.tooltipContainer?.remove();
80
71
  this.tooltipContainer = null;
81
72
  }
73
+
74
+ getPositionStyle(el, position) {
75
+ const { top, bottom, left, right, width, height } = el.getBoundingClientRect();
76
+ const { width: tooltipWidth, height: tooltipHeight } =
77
+ this.tooltipContainer.firstChild.getBoundingClientRect();
78
+
79
+ const scrollTop = document.documentElement.scrollTop;
80
+
81
+ let styles = `
82
+ bottom: auto!important;
83
+ right: auto!important;
84
+ transform: none!important;
85
+ `;
86
+
87
+ switch (position) {
88
+ case "bottomCenter":
89
+ styles =
90
+ styles +
91
+ `left: ${left + width / 2 - tooltipWidth / 2}px!important;
92
+ top: ${bottom + scrollTop + 5}px!important;`;
93
+ break;
94
+ case "bottomLeft":
95
+ styles =
96
+ styles +
97
+ `left: ${right - tooltipWidth - width / 2 + 14}px!important;
98
+ top: ${bottom + scrollTop + 5}px!important;`;
99
+ break;
100
+ case "bottomRight":
101
+ styles =
102
+ styles +
103
+ `left: ${left + width / 2 - 14}px!important;
104
+ top: ${bottom + scrollTop + 5}px!important;`;
105
+ break;
106
+ case "topLeft":
107
+ styles =
108
+ styles +
109
+ `left: ${right - tooltipWidth - width / 2 + 14}px!important;
110
+ top: ${top - tooltipHeight + scrollTop - 5}px!important;`;
111
+ break;
112
+ case "topRight":
113
+ styles =
114
+ styles +
115
+ `left: ${left + width / 2 - 14}px!important;
116
+ top: ${top - tooltipHeight + scrollTop - 5}px!important;`;
117
+ break;
118
+ case "leftTop":
119
+ styles =
120
+ styles +
121
+ `left: ${left - tooltipWidth - 5}px!important;
122
+ top: ${
123
+ bottom - tooltipHeight - height / 2 + scrollTop + 12
124
+ }px!important`;
125
+ break;
126
+ case "leftCenter":
127
+ styles =
128
+ styles +
129
+ `left: ${left - tooltipWidth - 5}px!important;
130
+ top: ${
131
+ bottom + scrollTop - tooltipHeight / 2 - height / 2
132
+ }px!important;`;
133
+ break;
134
+ case "leftBottom":
135
+ styles =
136
+ styles +
137
+ `left: ${left - tooltipWidth - 5}px!important;
138
+ top: ${bottom + scrollTop - height / 2 - 12}px!important;`;
139
+ break;
140
+ case "rightTop":
141
+ styles =
142
+ styles +
143
+ `left: ${right + 5}px!important;
144
+ top: ${
145
+ bottom - tooltipHeight - height / 2 + scrollTop + 12
146
+ }px!important`;
147
+ break;
148
+ case "rightCenter":
149
+ styles =
150
+ styles +
151
+ `left: ${right + 5}px!important;
152
+ top: ${
153
+ bottom + scrollTop - tooltipHeight / 2 - height / 2
154
+ }px!important;`;
155
+ break;
156
+
157
+ case "rightBottom":
158
+ styles =
159
+ styles +
160
+ `left: ${right + 5}px!important;
161
+ top: ${bottom + scrollTop - height / 2 - 12}px!important`;
162
+ break;
163
+ default:
164
+ styles =
165
+ styles +
166
+ `left: ${left + width / 2 - tooltipWidth / 2}px!important;
167
+ top: ${top - tooltipHeight + scrollTop - 5}px!important`;
168
+ break;
169
+ }
170
+
171
+ return styles;
172
+ }
173
+
174
+ getClassList(position) {
175
+ if (!position) {
176
+ return popoverPosition.topCenter;
177
+ }
178
+
179
+ return popoverPosition[position];
180
+ }
82
181
  }