aloha-vue 1.0.200 → 1.0.202

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.
@@ -12,6 +12,7 @@ export default {
12
12
  label: "Tab 1",
13
13
  id: "tab_1",
14
14
  content: "CONTENT 1",
15
+ title: "ALoha sdfdsfds sdfsdfdsf",
15
16
  },
16
17
  {
17
18
  label: "Tab 2",
@@ -2,6 +2,7 @@ div
2
2
  h1 ATabs
3
3
  a-tabs(
4
4
  :data="dataTabs1"
5
+ :index-active-tab="1"
5
6
  )
6
7
  br
7
8
  a-tabs(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.200",
4
+ "version": "1.0.202",
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"
@@ -139,7 +139,9 @@ export default {
139
139
  const tableId = inject("tableId");
140
140
  const eventName = `eventATableFilterTopOnOpen_${ tableId.value }`;
141
141
  const goToFilter = () => {
142
- EventBus.$emit(eventName);
142
+ if (!filter.value.main) {
143
+ EventBus.$emit(eventName);
144
+ }
143
145
 
144
146
  const FILTER_HTML_ID = getHtmlId({
145
147
  id: filter.value.id,
@@ -8,6 +8,8 @@ import AIcon from "../../AIcon/AIcon";
8
8
  import ATableFiltersTopFilter from "./ATableFiltersTopFilter";
9
9
  import ATableFiltersTopFilterUi from "./ATableFiltersTopFilterUi";
10
10
 
11
+ import VisibleAPI from "./compositionAPI/VisibleAPI";
12
+
11
13
  import EventBus from "../../utils/EventBus";
12
14
 
13
15
  export default {
@@ -83,6 +85,10 @@ export default {
83
85
  $event.preventDefault();
84
86
  };
85
87
 
88
+ const {
89
+ isBtnToggleVisible,
90
+ } = VisibleAPI(props);
91
+
86
92
  initEventBus();
87
93
 
88
94
  onBeforeUnmount(() => {
@@ -91,6 +97,7 @@ export default {
91
97
 
92
98
  return {
93
99
  iconToggle,
100
+ isBtnToggleVisible,
94
101
  isOpen,
95
102
  onSearch,
96
103
  onToggle,
@@ -135,10 +142,9 @@ export default {
135
142
  }),
136
143
  !this.isOpen && BUTTON_SEARCH,
137
144
  ]),
138
- h("div", {
145
+ this.isBtnToggleVisible && h("div", {
139
146
  class: "a_column",
140
147
  }, [
141
-
142
148
  h("button", {
143
149
  class: "a_btn a_btn_link a_text_nowrap",
144
150
  type: "button",
@@ -0,0 +1,17 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function VisibleAPI(props) {
7
+ const filtersVisible = toRef(props, "filtersVisible");
8
+ const filtersGroup = toRef(props, "filtersGroup");
9
+
10
+ const isBtnToggleVisible = computed(() => {
11
+ return !!(filtersVisible.value.length || filtersGroup.value.alwaysVisible.length);
12
+ });
13
+
14
+ return {
15
+ isBtnToggleVisible,
16
+ };
17
+ }
@@ -1,18 +1,14 @@
1
1
  import {
2
2
  h,
3
- ref,
4
- toRef,
5
- watch,
6
3
  } from "vue";
7
4
 
8
- import ATabsContent from "./ATabsContent";
9
- import ATabsTab from "./ATabsTab";
5
+ import ATabsContent from "./ATabsContent/ATabsContent";
6
+ import ATabsTab from "./ATabsTab/ATabsTab";
10
7
 
8
+ import ActiveAPI from "./compositionAPI/ActiveAPI";
9
+
10
+ import placements from "../const/placements";
11
11
  import {
12
- forEach,
13
- get,
14
- isNil,
15
- isUndefined,
16
12
  uniqueId,
17
13
  } from "lodash-es";
18
14
 
@@ -28,16 +24,11 @@ export default {
28
24
  type: Array,
29
25
  required: true,
30
26
  },
31
- idForActiveTab: {
32
- type: [String, Number],
27
+ indexActiveTab: {
28
+ type: Number,
33
29
  required: false,
34
30
  default: undefined,
35
31
  },
36
- keyId: {
37
- type: String,
38
- required: false,
39
- default: "id",
40
- },
41
32
  isChangeOutside: {
42
33
  type: Boolean,
43
34
  required: false,
@@ -46,56 +37,32 @@ export default {
46
37
  type: Boolean,
47
38
  required: false,
48
39
  },
40
+ disabled: {
41
+ type: Boolean,
42
+ required: false,
43
+ },
44
+ titlePlacement: {
45
+ type: String,
46
+ required: false,
47
+ default: "top",
48
+ validator: placement => placements.indexOf(placement) !== -1,
49
+ },
49
50
  },
50
51
  emits: [
51
52
  "change",
52
53
  ],
53
- setup(props, { emit }) {
54
- const idForActiveTabLocal = ref(undefined);
55
-
56
- const idForActiveTab = toRef(props, "idForActiveTab");
57
- const data = toRef(props, "data");
58
- const keyId = toRef(props, "keyId");
59
- const initTabActiveId = () => {
60
- if (!isNil(idForActiveTab.value)) {
61
- idForActiveTabLocal.value = idForActiveTab.value;
62
- return;
63
- }
64
-
65
- forEach(data.value, item => {
66
- if (item.active) {
67
- idForActiveTabLocal.value = item.id;
68
- return false;
69
- }
70
- });
71
- if (isUndefined(idForActiveTabLocal.value)) {
72
- idForActiveTabLocal.value = get(data.value[0], keyId.value);
73
- }
74
- };
75
-
76
- const isChangeOutside = toRef(props, "isChangeOutside");
77
- const onChangeTab = ({ $event, tab }) => {
78
- const TAB_ID = get(tab, keyId.value);
79
- if (idForActiveTabLocal.value === TAB_ID) {
80
- return;
81
- }
82
- if (!isChangeOutside.value) {
83
- idForActiveTabLocal.value = TAB_ID;
84
- }
85
- emit("change", { $event, tab });
86
- };
87
-
88
- watch(idForActiveTab, () => {
89
- if (idForActiveTab.value) {
90
- idForActiveTabLocal.value = idForActiveTab.value;
91
- }
92
- });
54
+ setup(props, context) {
55
+ const {
56
+ changeTab,
57
+ indexActiveTabLocal,
58
+ initTabActiveIndex,
59
+ } = ActiveAPI(props, context);
93
60
 
94
- initTabActiveId();
61
+ initTabActiveIndex();
95
62
 
96
63
  return {
97
- idForActiveTabLocal,
98
- onChangeTab,
64
+ indexActiveTabLocal,
65
+ changeTab,
99
66
  };
100
67
  },
101
68
  render() {
@@ -118,9 +85,10 @@ export default {
118
85
  tab,
119
86
  index: tabIndex,
120
87
  parentId: this.id,
121
- idForActiveTab: this.idForActiveTabLocal,
122
- keyId: this.keyId,
123
- onChangeTab: this.onChangeTab,
88
+ indexActiveTabLocal: this.indexActiveTabLocal,
89
+ disabled: this.disabled,
90
+ titlePlacement: this.titlePlacement,
91
+ onChangeTab: this.changeTab,
124
92
  });
125
93
  }),
126
94
  ]),
@@ -134,8 +102,7 @@ export default {
134
102
  tab,
135
103
  index: tabIndex,
136
104
  parentId: this.id,
137
- keyId: this.keyId,
138
- idForActiveTab: this.idForActiveTabLocal,
105
+ indexActiveTabLocal: this.indexActiveTabLocal,
139
106
  }, this.$slots);
140
107
  }),
141
108
  ]),
@@ -3,9 +3,9 @@ import {
3
3
  withDirectives,
4
4
  } from "vue";
5
5
 
6
- import ASafeHtml from "../directives/ASafeHtml";
6
+ import ASafeHtml from "../../directives/ASafeHtml";
7
7
 
8
- import ATabAPI from "./compositionAPI/ATabAPI";
8
+ import ATabAPI from "../compositionAPI/ATabAPI";
9
9
 
10
10
  export default {
11
11
  name: "ATabsContent",
@@ -22,12 +22,8 @@ export default {
22
22
  type: Number,
23
23
  required: true,
24
24
  },
25
- idForActiveTab: {
26
- type: [String, Number],
27
- required: true,
28
- },
29
- keyId: {
30
- type: String,
25
+ indexActiveTabLocal: {
26
+ type: Number,
31
27
  required: true,
32
28
  },
33
29
  },
@@ -0,0 +1,117 @@
1
+ import {
2
+ h,
3
+ withDirectives,
4
+ } from "vue";
5
+
6
+ import ATooltip from "../../ATooltip/ATooltip";
7
+
8
+ import ASafeHtml from "../../directives/ASafeHtml";
9
+
10
+ import ATabAPI from "../compositionAPI/ATabAPI";
11
+ import AttributesAPI from "./compositionAPI/AttributesAPI";
12
+ import ChangeAPI from "./compositionAPI/ChangeAPI";
13
+ import placements from "../../const/placements";
14
+
15
+ export default {
16
+ name: "ATabsTab",
17
+ props: {
18
+ parentId: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ tab: {
23
+ type: Object,
24
+ required: true,
25
+ },
26
+ index: {
27
+ type: Number,
28
+ required: true,
29
+ },
30
+ indexActiveTabLocal: {
31
+ type: Number,
32
+ required: true,
33
+ },
34
+ disabled: {
35
+ type: Boolean,
36
+ required: false,
37
+ },
38
+ titlePlacement: {
39
+ type: String,
40
+ required: false,
41
+ default: "top",
42
+ validator: placement => placements.indexOf(placement) !== -1,
43
+ },
44
+ },
45
+ emits: [
46
+ "changeTab",
47
+ ],
48
+ setup(props, context) {
49
+ const {
50
+ idForContent,
51
+ idLocal,
52
+ isActive,
53
+ } = ATabAPI(props);
54
+
55
+ const {
56
+ isDisabled,
57
+ tabindexLocal,
58
+ } = AttributesAPI(props);
59
+
60
+ const {
61
+ changeTabLocal,
62
+ keydownTab,
63
+ } = ChangeAPI(props, context, {
64
+ isDisabled,
65
+ });
66
+
67
+ return {
68
+ changeTabLocal,
69
+ idForContent,
70
+ idLocal,
71
+ isActive,
72
+ isDisabled,
73
+ keydownTab,
74
+ tabindexLocal,
75
+ };
76
+ },
77
+ render() {
78
+ return h(ATooltip, {
79
+ tag: "li",
80
+ placement: this.titlePlacement,
81
+ isHide: !this.tab.title,
82
+ class: [
83
+ "a_tabs__list__item",
84
+ this.tab.classLi,
85
+ ],
86
+ }, {
87
+ default: () => [
88
+ h("a", {
89
+ id: this.idLocal,
90
+ class: ["a_tabs__list__link", this.tab.class, {
91
+ a_tabs__list__link_active: this.isActive,
92
+ a_tabs__list__link_disabled: this.isDisabled,
93
+ }],
94
+ role: "tab",
95
+ ariaDisabled: this.tab.disabled,
96
+ ariaControls: this.idForContent,
97
+ ariaSelected: this.isActive,
98
+ tabindex: this.tabindexLocal,
99
+ onClick: this.changeTabLocal,
100
+ onKeydown: this.keydownTab,
101
+ }, [
102
+ this.tab.title && h("span", {
103
+ class: "a_position_absolute_all",
104
+ title: this.tab.title,
105
+ ariaHidden: true,
106
+ }),
107
+ withDirectives(h("span"), [
108
+ [ASafeHtml, this.tab.label],
109
+ ]),
110
+ ]),
111
+ ],
112
+ title: () => withDirectives(h("div"), [
113
+ [ASafeHtml, this.tab.title],
114
+ ])
115
+ });
116
+ },
117
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function AttributesAPI(props) {
7
+ const tab = toRef(props, "tab");
8
+ const disabled = toRef(props, "disabled");
9
+
10
+ const isDisabled = computed(() => {
11
+ return !!(disabled.value || tab.value.disabled);
12
+ });
13
+
14
+ const tabindexLocal = computed(() => {
15
+ return isDisabled.value ? -1 : 0;
16
+ });
17
+
18
+ return {
19
+ isDisabled,
20
+ tabindexLocal,
21
+ };
22
+ }
@@ -0,0 +1,33 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import AKeysCode from "../../../const/AKeysCode";
7
+
8
+ export default function ChangeAPI(props, { emit }, {
9
+ isDisabled = computed(() => false),
10
+ }) {
11
+ const tab = toRef(props, "tab");
12
+ const index = toRef(props, "index");
13
+ const changeTabLocal = $event => {
14
+ if (isDisabled.value) {
15
+ return;
16
+ }
17
+ emit("changeTab", { $event, tab: tab.value, tabIndex: index.value });
18
+ };
19
+
20
+ const keydownTab = $event => {
21
+ if ($event.keyCode === AKeysCode.enter ||
22
+ $event.keyCode === AKeysCode.space) {
23
+ changeTabLocal($event);
24
+ $event.stopPropagation();
25
+ $event.preventDefault();
26
+ }
27
+ };
28
+
29
+ return {
30
+ changeTabLocal,
31
+ keydownTab,
32
+ };
33
+ }
@@ -3,13 +3,15 @@ import {
3
3
  toRef,
4
4
  } from "vue";
5
5
 
6
- import {
7
- get,
8
- } from "lodash-es";
9
-
10
6
  export default function ATabAPI(props) {
11
7
  const parentId = toRef(props, "parentId");
12
8
  const index = toRef(props, "index");
9
+ const indexActiveTabLocal = toRef(props, "indexActiveTabLocal");
10
+
11
+ const isActive = computed(() => {
12
+ return indexActiveTabLocal.value === index.value;
13
+ });
14
+
13
15
  const idLocal = computed(() => {
14
16
  return `${ parentId.value }_${ index.value }`;
15
17
  });
@@ -18,17 +20,6 @@ export default function ATabAPI(props) {
18
20
  return `${ idLocal.value }_content`;
19
21
  });
20
22
 
21
- const tab = toRef(props, "tab");
22
- const keyId = toRef(props, "keyId");
23
- const tabId = computed(() => {
24
- return get(tab.value, keyId.value);
25
- });
26
-
27
- const idForActiveTab = toRef(props, "idForActiveTab");
28
- const isActive = computed(() => {
29
- return idForActiveTab.value === tabId.value;
30
- });
31
-
32
23
  return {
33
24
  idForContent,
34
25
  idLocal,
@@ -0,0 +1,59 @@
1
+ import {
2
+ ref,
3
+ toRef,
4
+ watch,
5
+ } from "vue";
6
+
7
+ import {
8
+ forEach,
9
+ isNil,
10
+ } from "lodash-es";
11
+
12
+ export default function ActiveAPI(props, { emit }) {
13
+ const indexActiveTab = toRef(props, "indexActiveTab");
14
+ const data = toRef(props, "data");
15
+ const isChangeOutside = toRef(props, "isChangeOutside");
16
+
17
+ const indexActiveTabLocal = ref(0);
18
+
19
+ const setIndexActiveTabLocal = () => {
20
+ if (!isNil(indexActiveTab.value)) {
21
+ indexActiveTabLocal.value = indexActiveTab.value;
22
+ }
23
+ };
24
+
25
+ const initTabActiveIndex = () => {
26
+ setIndexActiveTabLocal();
27
+
28
+ if (!isNil(indexActiveTabLocal.value)) {
29
+ return;
30
+ }
31
+
32
+ forEach(data.value, (item, index) => {
33
+ if (item.active) {
34
+ indexActiveTabLocal.value = index;
35
+ return false;
36
+ }
37
+ });
38
+ };
39
+
40
+ const changeTab = ({ $event, tab, tabIndex }) => {
41
+ if (indexActiveTabLocal.value === tabIndex) {
42
+ return;
43
+ }
44
+ if (!isChangeOutside.value) {
45
+ indexActiveTabLocal.value = tabIndex;
46
+ }
47
+ emit("change", { $event, tab, tabIndex });
48
+ };
49
+
50
+ watch(indexActiveTab, () => {
51
+ setIndexActiveTabLocal();
52
+ });
53
+
54
+ return {
55
+ changeTab,
56
+ indexActiveTabLocal,
57
+ initTabActiveIndex,
58
+ };
59
+ }
@@ -1,107 +0,0 @@
1
- import {
2
- computed,
3
- h,
4
- toRef,
5
- withDirectives,
6
- } from "vue";
7
-
8
- import ASafeHtml from "../directives/ASafeHtml";
9
-
10
- import ATabAPI from "./compositionAPI/ATabAPI";
11
-
12
- import AKeysCode from "../const/AKeysCode";
13
-
14
- export default {
15
- name: "ATabsTab",
16
- props: {
17
- parentId: {
18
- type: String,
19
- required: true,
20
- },
21
- tab: {
22
- type: Object,
23
- required: true,
24
- },
25
- index: {
26
- type: Number,
27
- required: true,
28
- },
29
- idForActiveTab: {
30
- type: [String, Number],
31
- required: true,
32
- },
33
- keyId: {
34
- type: String,
35
- required: true,
36
- },
37
- },
38
- emits: [
39
- "changeTab",
40
- ],
41
- setup(props, { emit }) {
42
- const {
43
- idForContent,
44
- idLocal,
45
- isActive,
46
- } = ATabAPI(props);
47
-
48
- const tab = toRef(props, "tab");
49
- const onChangeTabLocal = $event => {
50
- if (tab.value.disabled) {
51
- return;
52
- }
53
- emit("changeTab", { $event, tab: tab.value });
54
- };
55
-
56
- const tabindexLocal = computed(() => {
57
- return tab.value.disabled ? -1 : 0;
58
- });
59
-
60
- const onKeydown = $event => {
61
- if ($event.keyCode === AKeysCode.enter ||
62
- $event.keyCode === AKeysCode.space) {
63
- onChangeTabLocal($event);
64
- $event.stopPropagation();
65
- $event.preventDefault();
66
- }
67
- };
68
-
69
- return {
70
- idForContent,
71
- idLocal,
72
- isActive,
73
- onChangeTabLocal,
74
- onKeydown,
75
- tabindexLocal,
76
- };
77
- },
78
- render() {
79
- return h("li", {
80
- class: "a_tabs__list__item",
81
- }, [
82
- h("a", {
83
- id: this.idLocal,
84
- class: ["a_tabs__list__link", this.tab.class, {
85
- a_tabs__list__link_active: this.isActive,
86
- a_tabs__list__link_disabled: this.tab.disabled,
87
- }],
88
- role: "tab",
89
- ariaDisabled: this.tab.disabled,
90
- ariaControls: this.idForContent,
91
- ariaSelected: this.isActive,
92
- tabindex: this.tabindexLocal,
93
- onClick: this.onChangeTabLocal,
94
- onKeydown: this.onKeydown,
95
- }, [
96
- this.tab.title && h("span", {
97
- class: "a_position_absolute_all",
98
- title: this.tab.title,
99
- ariaHidden: true,
100
- }),
101
- withDirectives(h("span"), [
102
- [ASafeHtml, this.tab.label],
103
- ]),
104
- ]),
105
- ]);
106
- },
107
- };