aloha-vue 1.0.162 → 1.0.164

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/docs/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@popperjs/core": "2.11.6",
15
- "aloha-css": "1.0.65",
15
+ "aloha-css": "1.0.70",
16
16
  "fecha": "^4.2.3",
17
17
  "lodash-es": "^4.17.21",
18
18
  "tiny-emitter": "2.1.0",
@@ -244,6 +244,15 @@ export default {
244
244
  },
245
245
  icon: "Dnd",
246
246
  },
247
+ {
248
+ id: "title",
249
+ label: "Title",
250
+ to: {
251
+ name: "PageTitle",
252
+ },
253
+ icon: "Dnd",
254
+ titleHtml: "PageTitle",
255
+ },
247
256
  ],
248
257
  };
249
258
  },
@@ -134,6 +134,11 @@ const ROUTES = [
134
134
  name: "PageScale",
135
135
  component: () => import(/* webpackChunkName: "PageScale" */ "../views/PageScale/PageScale.vue"),
136
136
  },
137
+ {
138
+ path: "/title",
139
+ name: "PageTitle",
140
+ component: () => import(/* webpackChunkName: "PageTitle" */ "../views/PageTitle/PageTitle.vue"),
141
+ },
137
142
  {
138
143
  // If the routing configuration '*' reports an error, replace it with '/: catchAll(. *)'
139
144
  // caught Error: Catch all routes ("*") must now be defined using a param with a custom regexp
@@ -0,0 +1,13 @@
1
+ import ATooltip from "../../../../src/ATooltip/ATooltip";
2
+
3
+ export default {
4
+ name: "PageTitle",
5
+ components: {
6
+ ATooltip,
7
+ },
8
+ setup() {
9
+ return {
10
+
11
+ };
12
+ },
13
+ };
@@ -0,0 +1,12 @@
1
+ div
2
+ h1 ATitle
3
+
4
+ a-tooltip.a_btn.a_btn_primary(
5
+ tag="button"
6
+ )
7
+ span Test
8
+
9
+ template(
10
+ v-slot:title
11
+ )
12
+ div ALoha
@@ -0,0 +1,2 @@
1
+ <template lang="pug" src="./PageTitle.pug"></template>
2
+ <script src="./PageTitle.js"></script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.162",
4
+ "version": "1.0.164",
5
5
  "author": "Ilia Brykin",
6
6
  "scripts": {
7
7
  "build-icons": "node scriptsNode/iconsSvgToJs.js bootstrap3 && node scriptsNode/iconsSvgToJs.js bootstrap-1-9-1"
@@ -7,6 +7,7 @@ import AIcon from "../AIcon/AIcon";
7
7
  import ATranslation from "../ATranslation/ATranslation";
8
8
 
9
9
  import AKeysCode from "../const/AKeysCode";
10
+ import placements from "../const/placements";
10
11
  import {
11
12
  createPopper,
12
13
  } from "@popperjs/core";
@@ -17,23 +18,6 @@ import {
17
18
  } from "lodash-es";
18
19
 
19
20
  const ELEMENTS_FOR_ARROWS = `button:not([disabled]), input:not([disabled]), a`;
20
- const AVAILABLE_POSITIONS = [
21
- "auto",
22
- "auto-start",
23
- "auto-end",
24
- "top",
25
- "top-start",
26
- "top-end",
27
- "right",
28
- "right-start",
29
- "right-end",
30
- "bottom",
31
- "bottom-start",
32
- "bottom-end",
33
- "left",
34
- "left-start",
35
- "left-end",
36
- ];
37
21
 
38
22
  export default {
39
23
  name: "ADropdown",
@@ -107,7 +91,7 @@ export default {
107
91
  type: String,
108
92
  required: false,
109
93
  default: "bottom-start",
110
- validator: placement => AVAILABLE_POSITIONS.indexOf(placement) !== -1,
94
+ validator: placement => placements.indexOf(placement) !== -1,
111
95
  },
112
96
  isCaret: {
113
97
  type: Boolean,
@@ -2,7 +2,7 @@ import {
2
2
  h,
3
3
  } from "vue";
4
4
 
5
- import AMenuPanelLink from "./AMenuPanelLink";
5
+ import AMenuPanelLink from "./AMenuPanelLink/AMenuPanelLink";
6
6
 
7
7
  export default {
8
8
  name: "AMenuPanelGroup",
@@ -2,21 +2,22 @@ import {
2
2
  computed,
3
3
  h,
4
4
  inject,
5
- resolveComponent,
6
5
  toRef,
7
6
  } from "vue";
8
7
 
9
- import AIcon from "../AIcon/AIcon";
8
+ import AIcon from "../../AIcon/AIcon";
9
+ import ATooltip from "../../ATooltip/ATooltip";
10
10
 
11
- import AFiltersAPI from "../compositionAPI/AFiltersAPI";
11
+ import AFiltersAPI from "../../compositionAPI/AFiltersAPI";
12
+ import TitleAPI from "./compositionAPI/TitleAPI";
12
13
 
13
- import AKeyId from "../ui/const/AKeyId";
14
- import AKeyLabel from "../ui/const/AKeyLabel";
15
- import AKeyParent from "../ui/const/AKeyParent";
16
- import AKeysCode from "../const/AKeysCode";
14
+ import AKeyId from "../../ui/const/AKeyId";
15
+ import AKeyLabel from "../../ui/const/AKeyLabel";
16
+ import AKeyParent from "../../ui/const/AKeyParent";
17
+ import AKeysCode from "../../const/AKeysCode";
17
18
  import {
18
19
  setFocusToFirstLinkInPanel
19
- } from "./utils/utils";
20
+ } from "../utils/utils";
20
21
  import {
21
22
  get,
22
23
  } from "lodash-es";
@@ -121,10 +122,6 @@ export default {
121
122
  return dataProParentChildren.value[id.value] && dataProParentChildren.value[id.value].length;
122
123
  });
123
124
 
124
- const title = computed(() => {
125
- return item.value.title || labelWithoutFilter.value;
126
- });
127
-
128
125
  const toLocal = computed(() => {
129
126
  if (isLinkDisabled.value) {
130
127
  return "#";
@@ -154,6 +151,13 @@ export default {
154
151
  clickMenuLink();
155
152
  };
156
153
 
154
+ const {
155
+ isTitleHtml,
156
+ title,
157
+ } = TitleAPI(props, {
158
+ labelWithoutFilter,
159
+ });
160
+
157
161
  return {
158
162
  clickLink,
159
163
  countChildren,
@@ -162,6 +166,7 @@ export default {
162
166
  isLinkDisabled,
163
167
  isLinkTruncated,
164
168
  isLinkVisible,
169
+ isTitleHtml,
165
170
  label,
166
171
  labelWithoutFilter,
167
172
  onKeydown,
@@ -182,7 +187,7 @@ export default {
182
187
  h("span", {
183
188
  class: "a_menu__link__text",
184
189
  }, [
185
- h("span", {
190
+ this.title && h("span", {
186
191
  class: "a_position_absolute_all",
187
192
  title: this.title,
188
193
  ariaHidden: true,
@@ -208,14 +213,22 @@ export default {
208
213
  labelWithoutFilter: this.labelWithoutFilter,
209
214
  }) :
210
215
  this.item.to ?
211
- h(resolveComponent("RouterLink"), {
216
+ h(ATooltip, {
217
+ tag: "RouterLink",
218
+ placement: "right",
219
+ isHide: !this.isTitleHtml,
212
220
  class: ["a_menu__link a_menu__link__text_truncated", {
213
221
  a_menu__link_disabled: this.isLinkDisabled,
214
222
  }],
215
223
  to: this.toLocal,
216
224
  tabindex: this.isPanelOpen ? 0 : -1,
217
225
  onClick: this.clickLink,
218
- }, () => ICON_AND_TEXT) :
226
+ }, {
227
+ default: () => ICON_AND_TEXT,
228
+ title: () => h("div", {
229
+ innerHTML: this.item.titleHtml,
230
+ })
231
+ }) :
219
232
  h("a", {
220
233
  class: "a_menu__link a_menu__link_btn a_menu__link__text_truncated",
221
234
  ariaLabel: "Untermenü öffnen",
@@ -0,0 +1,26 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function TitleAPI(props, {
7
+ labelWithoutFilter = computed(() => ""),
8
+ }) {
9
+ const item = toRef(props, "item");
10
+
11
+ const isTitleHtml = computed(() => {
12
+ return !!item.value.titleHtml;
13
+ });
14
+
15
+ const title = computed(() => {
16
+ if (isTitleHtml.value) {
17
+ return undefined;
18
+ }
19
+ return item.value.title || labelWithoutFilter.value;
20
+ });
21
+
22
+ return {
23
+ isTitleHtml,
24
+ title,
25
+ };
26
+ }
@@ -3,7 +3,7 @@ import {
3
3
  h, toRef,
4
4
  } from "vue";
5
5
 
6
- import AMenuPanelLink from "./AMenuPanelLink";
6
+ import AMenuPanelLink from "./AMenuPanelLink/AMenuPanelLink";
7
7
 
8
8
  import AKeyParent from "../ui/const/AKeyParent";
9
9
  import AKeyLabel from "../ui/const/AKeyLabel";
@@ -0,0 +1,136 @@
1
+ import {
2
+ h,
3
+ Teleport,
4
+ } from "vue";
5
+
6
+ import AttributesAPI from "./compositionAPI/AttributesAPI";
7
+ import PopperAPI from "./compositionAPI/PopperAPI";
8
+ import TagAPI from "./compositionAPI/TagAPI";
9
+ import ToggleAPI from "./compositionAPI/ToggleAPI";
10
+
11
+ import placements from "../const/placements";
12
+ import {
13
+ uniqueId,
14
+ } from "lodash-es";
15
+
16
+ export default {
17
+ name: "ATooltip",
18
+ props: {
19
+ id: {
20
+ type: String,
21
+ required: false,
22
+ default: () => uniqueId("a_tooltip"),
23
+ },
24
+ placement: {
25
+ type: String,
26
+ required: false,
27
+ default: "bottom-start",
28
+ validator: placement => placements.indexOf(placement) !== -1,
29
+ },
30
+ tag: {
31
+ type: String,
32
+ required: false,
33
+ default: "span",
34
+ },
35
+ isHide: {
36
+ type: Boolean,
37
+ required: false,
38
+ },
39
+ timeClose: {
40
+ type: Number,
41
+ required: false,
42
+ default: 300,
43
+ },
44
+ },
45
+ setup(props) {
46
+ const {
47
+ closeTitle,
48
+ closeTitleWithTimer,
49
+ componentRef,
50
+ isTitleVisible,
51
+ mouseEnterTooltip,
52
+ mouseLeaveTooltip,
53
+ showTitle,
54
+ titleRef,
55
+ updateTitle,
56
+ updateTitleOptions,
57
+ } = PopperAPI(props);
58
+
59
+ const {
60
+ onBlur,
61
+ onFocus,
62
+ onMouseenter,
63
+ onMouseleave,
64
+ } = ToggleAPI(props, {
65
+ showTitle,
66
+ closeTitle,
67
+ closeTitleWithTimer,
68
+ });
69
+
70
+ const {
71
+ tagLocal,
72
+ } = TagAPI(props);
73
+
74
+ const {
75
+ ariaDescribedby,
76
+ } = AttributesAPI(props);
77
+
78
+ return {
79
+ ariaDescribedby,
80
+ closeTitle,
81
+ componentRef,
82
+ isTitleVisible,
83
+ mouseEnterTooltip,
84
+ mouseLeaveTooltip,
85
+ onBlur,
86
+ onFocus,
87
+ onMouseenter,
88
+ onMouseleave,
89
+ showTitle,
90
+ tagLocal,
91
+ titleRef,
92
+ updateTitle,
93
+ updateTitleOptions,
94
+ };
95
+ },
96
+ render() {
97
+ return h(this.tagLocal, {
98
+ ref: "componentRef",
99
+ id: this.id,
100
+ "aria-describedby": this.ariaDescribedby,
101
+ onFocus: this.onFocus,
102
+ onBlur: this.onBlur,
103
+ onMouseenter: this.onMouseenter,
104
+ onMouseleave: this.onMouseleave,
105
+ }, {
106
+ default: () => [
107
+ this.$slots.default && this.$slots.default(),
108
+ !this.isHide && h(Teleport, {
109
+ to: "body",
110
+ }, [
111
+ h("div", {
112
+ ariaHidden: true,
113
+ }, [
114
+ h("div", {
115
+ id: this.ariaDescribedby
116
+ }, [
117
+ this.$slots.title && this.$slots.title(),
118
+ ]),
119
+ this.isTitleVisible && h("div", {
120
+ ref: "titleRef",
121
+ class: "a_tooltip__container",
122
+ onMouseenter: this.mouseEnterTooltip,
123
+ onMouseleave: this.mouseLeaveTooltip,
124
+ }, [
125
+ this.$slots.title && this.$slots.title(),
126
+ h("div", {
127
+ "data-popper-arrow": true,
128
+ class: "a_tooltip__arrow",
129
+ }),
130
+ ]),
131
+ ]),
132
+ ]),
133
+ ],
134
+ });
135
+ },
136
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function AttributesAPI(props) {
7
+ const id = toRef(props, "id");
8
+
9
+ const ariaDescribedby = computed(() => {
10
+ return `${ id.value }_title`;
11
+ });
12
+
13
+ return {
14
+ ariaDescribedby,
15
+ };
16
+ }
@@ -0,0 +1,123 @@
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import EventBus from "../../utils/EventBus";
8
+ import {
9
+ createPopper,
10
+ } from "@popperjs/core";
11
+
12
+ export default function PopperAPI(props) {
13
+ const id = toRef(props, "id");
14
+ const placement = toRef(props, "placement");
15
+ const timeClose = toRef(props, "timeClose");
16
+
17
+ const popper = ref(undefined);
18
+ const timerTitleClose = ref(undefined);
19
+ const isTitleVisible = ref(false);
20
+ const titleRef = ref(undefined);
21
+ const componentRef = ref(undefined);
22
+
23
+ const popperOptions = computed(() => {
24
+ return {
25
+ placement: placement.value,
26
+ removeOnDestroy: true,
27
+ modifiers: [
28
+ {
29
+ name: "offset",
30
+ options: {
31
+ offset: [0, 6],
32
+ },
33
+ },
34
+ ],
35
+ };
36
+ });
37
+
38
+ const setEventBusCloseTitle = () => {
39
+ EventBus.$on("closeHtmlTitle", closeTitle);
40
+ };
41
+
42
+ const destroyEventBusCloseTitle = () => {
43
+ EventBus.$off("closeHtmlTitle", closeTitle);
44
+ };
45
+
46
+ const destroyPopper = () => {
47
+ if (popper.value) {
48
+ popper.value.destroy();
49
+ popper.value = undefined;
50
+ }
51
+ };
52
+
53
+ const closeTitleWithTimer = () => {
54
+ timerTitleClose.value = setTimeout(() => {
55
+ closeTitle();
56
+ }, timeClose.value);
57
+ };
58
+
59
+ const showTitle = () => {
60
+ if (isTitleVisible.value) {
61
+ clearTimeout(timerTitleClose.value);
62
+ return;
63
+ }
64
+ isTitleVisible.value = true;
65
+ setTimeout(() => {
66
+ if (!popper.value) {
67
+ const ELEMENT = document.getElementById(id.value);
68
+ if (!titleRef.value) {
69
+ return;
70
+ }
71
+ popper.value = createPopper(
72
+ ELEMENT,
73
+ titleRef.value,
74
+ popperOptions.value,
75
+ );
76
+ }
77
+ EventBus.$emit("closeHtmlTitle");
78
+ setEventBusCloseTitle();
79
+ });
80
+ };
81
+
82
+ const mouseEnterTooltip = () => {
83
+ clearTimeout(timerTitleClose.value);
84
+ };
85
+
86
+ const mouseLeaveTooltip = () => {
87
+ closeTitleWithTimer();
88
+ };
89
+
90
+ const updateTitle = () => {
91
+ if (popper.value) {
92
+ popper.value.forceUpdate();
93
+ // this.setContentSymbolsLengthInTooltipContent();
94
+ }
95
+ };
96
+
97
+ const updateTitleOptions = () => {
98
+ if (popper.value) {
99
+ popper.value.setOptions(popperOptions.value);
100
+ // this.setContentSymbolsLengthInTooltipContent();
101
+ }
102
+ };
103
+
104
+ function closeTitle() {
105
+ clearTimeout(timerTitleClose.value);
106
+ destroyPopper();
107
+ destroyEventBusCloseTitle();
108
+ isTitleVisible.value = false;
109
+ }
110
+
111
+ return {
112
+ closeTitle,
113
+ closeTitleWithTimer,
114
+ componentRef,
115
+ isTitleVisible,
116
+ mouseEnterTooltip,
117
+ mouseLeaveTooltip,
118
+ showTitle,
119
+ titleRef,
120
+ updateTitle,
121
+ updateTitleOptions,
122
+ };
123
+ }
@@ -0,0 +1,22 @@
1
+ import {
2
+ computed,
3
+ resolveComponent,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ const COMPONENTS = ["RouterLink", "router-link"];
8
+
9
+ export default function TagAPI(props) {
10
+ const tag = toRef(props, "tag");
11
+
12
+ const tagLocal = computed(() => {
13
+ if (COMPONENTS.indexOf(tag.value) !== -1) {
14
+ return resolveComponent(tag.value);
15
+ }
16
+ return tag.value;
17
+ });
18
+
19
+ return {
20
+ tagLocal,
21
+ };
22
+ }
@@ -0,0 +1,40 @@
1
+ import {
2
+ toRef,
3
+ } from "vue";
4
+
5
+ export default function ToggleAPI(props, {
6
+ showTitle = () => {},
7
+ closeTitle = () => {},
8
+ closeTitleWithTimer = () => {},
9
+ }) {
10
+ const isHide = toRef(props, "isHide");
11
+
12
+ const onMouseenter = () => {
13
+ if (isHide.value) {
14
+ return;
15
+ }
16
+ showTitle();
17
+ };
18
+
19
+ const onMouseleave = () => {
20
+ closeTitleWithTimer();
21
+ };
22
+
23
+ const onFocus = () => {
24
+ if (isHide.value) {
25
+ return;
26
+ }
27
+ showTitle();
28
+ };
29
+
30
+ const onBlur = () => {
31
+ closeTitle();
32
+ };
33
+
34
+ return {
35
+ onBlur,
36
+ onFocus,
37
+ onMouseenter,
38
+ onMouseleave,
39
+ };
40
+ }
@@ -0,0 +1,17 @@
1
+ export default [
2
+ "auto",
3
+ "auto-start",
4
+ "auto-end",
5
+ "top",
6
+ "top-start",
7
+ "top-end",
8
+ "right",
9
+ "right-start",
10
+ "right-end",
11
+ "bottom",
12
+ "bottom-start",
13
+ "bottom-end",
14
+ "left",
15
+ "left-start",
16
+ "left-end",
17
+ ];