aloha-vue 1.0.24 → 1.0.25

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.27",
15
+ "aloha-css": "1.0.29",
16
16
  "lodash-es": "^4.17.21",
17
17
  "vue": "3.2.31",
18
18
  "vue-router": "4.0.14",
@@ -88,6 +88,11 @@ export default {
88
88
  name: "PageDropdown",
89
89
  label: "Dropdown",
90
90
  },
91
+ {
92
+ id: "tabs",
93
+ name: "PageTabs",
94
+ label: "Tabs",
95
+ },
91
96
  ],
92
97
  };
93
98
  },
@@ -99,6 +99,11 @@ const ROUTES = [
99
99
  name: "PageDropdown",
100
100
  component: () => import(/* webpackChunkName: "PageDropdown" */ "../views/PageDropdown/PageDropdown.vue"),
101
101
  },
102
+ {
103
+ path: "/tabs",
104
+ name: "PageTabs",
105
+ component: () => import(/* webpackChunkName: "PageTabs" */ "../views/PageTabs/PageTabs.vue"),
106
+ },
102
107
  {
103
108
  // If the routing configuration '*' reports an error, replace it with '/: catchAll(. *)'
104
109
  // caught Error: Catch all routes ("*") must now be defined using a param with a custom regexp
@@ -0,0 +1,30 @@
1
+ import ATabs from "../../../../src/ATabs/ATabs";
2
+
3
+ export default {
4
+ name: "PageTabs",
5
+ components: {
6
+ ATabs,
7
+ },
8
+ data() {
9
+ return {
10
+ dataTabs1: [
11
+ {
12
+ label: "Tab 1",
13
+ id: "tab_1",
14
+ content: "CONTENT 1",
15
+ },
16
+ {
17
+ label: "Tab 2",
18
+ id: "tab_2",
19
+ content: "CONTENT 2",
20
+ },
21
+ {
22
+ label: "Tab 3",
23
+ id: "tab_3",
24
+ content: "CONTENT 3",
25
+ disabled: true,
26
+ },
27
+ ],
28
+ };
29
+ },
30
+ };
@@ -0,0 +1,25 @@
1
+ div
2
+ h1 ATabs
3
+ a-tabs(
4
+ :data="dataTabs1"
5
+ )
6
+ br
7
+ a-tabs(
8
+ :data="dataTabs1"
9
+ :is-boxed="true"
10
+ )
11
+ br
12
+ a-tabs.a_tabs_small(
13
+ :data="dataTabs1"
14
+ :is-boxed="true"
15
+ )
16
+ br
17
+ a-tabs.a_tabs_medium(
18
+ :data="dataTabs1"
19
+ :is-boxed="true"
20
+ )
21
+ br
22
+ a-tabs.a_tabs_large(
23
+ :data="dataTabs1"
24
+ :is-boxed="true"
25
+ )
@@ -0,0 +1,2 @@
1
+ <template lang="pug" src="./PageTabs.pug"></template>
2
+ <script src="./PageTabs.js"></script>
@@ -1,18 +1,3 @@
1
- html {
2
- box-sizing: border-box;
3
- }
4
-
5
- *, ::after, ::before {
6
- box-sizing: inherit;
7
- }
8
-
9
- body {
10
- margin: 0;
11
- }
12
-
13
- .a_search_highlight {
14
- color: red;
15
- }
16
1
  @import "./node_modules/aloha-css/sass/aloha";
17
2
 
18
3
  @import "../src/styles/styles";
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.24",
4
+ "version": "1.0.25",
5
5
  "author": "Ilia Brykin",
6
6
  "dependencies": {
7
7
  "@popperjs/core": "2.11.5",
8
- "aloha-css": "1.0.25",
8
+ "aloha-css": "1.0.29",
9
9
  "lodash-es": "^4.17.21",
10
10
  "vue": "3.2.37"
11
11
  }
@@ -0,0 +1,144 @@
1
+ import {
2
+ h,
3
+ ref,
4
+ toRef,
5
+ watch,
6
+ } from "vue";
7
+
8
+ import ATabsContent from "./ATabsContent";
9
+ import ATabsTab from "./ATabsTab";
10
+
11
+ import {
12
+ forEach,
13
+ get,
14
+ isNil,
15
+ isUndefined,
16
+ uniqueId,
17
+ } from "lodash-es";
18
+
19
+ export default {
20
+ name: "ATabs",
21
+ props: {
22
+ id: {
23
+ type: String,
24
+ required: false,
25
+ default: () => uniqueId("a_tabs_"),
26
+ },
27
+ data: {
28
+ type: Array,
29
+ required: true,
30
+ },
31
+ idForActiveTab: {
32
+ type: [String, Number],
33
+ required: false,
34
+ default: undefined,
35
+ },
36
+ keyId: {
37
+ type: String,
38
+ required: false,
39
+ default: "id",
40
+ },
41
+ isChangeOutside: {
42
+ type: Boolean,
43
+ required: false,
44
+ },
45
+ isBoxed: {
46
+ type: Boolean,
47
+ required: false,
48
+ },
49
+ },
50
+ emits: [
51
+ "change",
52
+ ],
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
+ });
93
+
94
+ initTabActiveId();
95
+
96
+ return {
97
+ idForActiveTabLocal,
98
+ onChangeTab,
99
+ };
100
+ },
101
+ render() {
102
+ return h("div", {
103
+ id: this.id,
104
+ class: ["a_tabs", {
105
+ a_tabs_boxed: this.isBoxed,
106
+ }],
107
+ }, [
108
+ h("div", {
109
+ class: "a_tabs__box",
110
+ }, [
111
+ h("ul", {
112
+ class: "a_tabs__list",
113
+ role: "tablist",
114
+ }, [
115
+ this.data.map((tab, tabIndex) => {
116
+ return h(ATabsTab, {
117
+ key: tabIndex,
118
+ tab,
119
+ index: tabIndex,
120
+ parentId: this.id,
121
+ idForActiveTab: this.idForActiveTabLocal,
122
+ keyId: this.keyId,
123
+ onChangeTab: this.onChangeTab,
124
+ });
125
+ }),
126
+ ]),
127
+ ]),
128
+ h("div", {
129
+ class: "a_tabs__contents",
130
+ }, [
131
+ this.data.map((tab, tabIndex) => {
132
+ return h(ATabsContent, {
133
+ key: tabIndex,
134
+ tab,
135
+ index: tabIndex,
136
+ parentId: this.id,
137
+ keyId: this.keyId,
138
+ idForActiveTab: this.idForActiveTabLocal,
139
+ }, this.$slots);
140
+ }),
141
+ ]),
142
+ ]);
143
+ },
144
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ h,
3
+ } from "vue";
4
+
5
+ import ATabAPI from "./compositionAPI/ATabAPI";
6
+
7
+ export default {
8
+ name: "ATabsContent",
9
+ props: {
10
+ parentId: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ tab: {
15
+ type: Object,
16
+ required: true,
17
+ },
18
+ index: {
19
+ type: Number,
20
+ required: true,
21
+ },
22
+ idForActiveTab: {
23
+ type: [String, Number],
24
+ required: true,
25
+ },
26
+ keyId: {
27
+ type: String,
28
+ required: true,
29
+ },
30
+ },
31
+ setup(props) {
32
+ const {
33
+ idForContent,
34
+ idLocal,
35
+ isActive,
36
+ } = ATabAPI(props);
37
+
38
+ return {
39
+ idForContent,
40
+ idLocal,
41
+ isActive,
42
+ };
43
+ },
44
+ render() {
45
+ return h("div", {
46
+ id: this.idForContent,
47
+ role: "tabpanel",
48
+ class: ["a_tabs__content", {
49
+ a_tabs__content_show: this.isActive,
50
+ }],
51
+ ariaLabelledby: this.idLocal,
52
+ }, [
53
+ this.tab.slotContent ?
54
+ this.$slots[this.tab.slotContent] &&
55
+ this.$slots[this.tab.slotContent]({ tab: this.tab }) :
56
+ this.tab.content &&
57
+ h("div", {
58
+ innerHTML: this.tab.content,
59
+ }),
60
+ ]);
61
+ },
62
+ };
@@ -0,0 +1,104 @@
1
+ import {
2
+ computed,
3
+ h,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import ATabAPI from "./compositionAPI/ATabAPI";
8
+
9
+ import AKeysCode from "../const/AKeysCode";
10
+
11
+ export default {
12
+ name: "ATabsTab",
13
+ props: {
14
+ parentId: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ tab: {
19
+ type: Object,
20
+ required: true,
21
+ },
22
+ index: {
23
+ type: Number,
24
+ required: true,
25
+ },
26
+ idForActiveTab: {
27
+ type: [String, Number],
28
+ required: true,
29
+ },
30
+ keyId: {
31
+ type: String,
32
+ required: true,
33
+ },
34
+ },
35
+ emits: [
36
+ "changeTab",
37
+ ],
38
+ setup(props, { emit }) {
39
+ const {
40
+ idForContent,
41
+ idLocal,
42
+ isActive,
43
+ } = ATabAPI(props);
44
+
45
+ const tab = toRef(props, "tab");
46
+ const onChangeTabLocal = $event => {
47
+ if (tab.value.disabled) {
48
+ return;
49
+ }
50
+ emit("changeTab", { $event, tab: tab.value });
51
+ };
52
+
53
+ const tabindexLocal = computed(() => {
54
+ return tab.value.disabled ? -1 : 0;
55
+ });
56
+
57
+ const onKeydown = $event => {
58
+ if ($event.keyCode === AKeysCode.enter ||
59
+ $event.keyCode === AKeysCode.space) {
60
+ onChangeTabLocal($event);
61
+ $event.stopPropagation();
62
+ $event.preventDefault();
63
+ }
64
+ };
65
+
66
+ return {
67
+ idForContent,
68
+ idLocal,
69
+ isActive,
70
+ onChangeTabLocal,
71
+ onKeydown,
72
+ tabindexLocal,
73
+ };
74
+ },
75
+ render() {
76
+ return h("li", {
77
+ class: "a_tabs__list__item",
78
+ }, [
79
+ h("a", {
80
+ id: this.idLocal,
81
+ class: ["a_tabs__list__link", this.tab.class, {
82
+ a_tabs__list__link_active: this.isActive,
83
+ a_tabs__list__link_disabled: this.tab.disabled,
84
+ }],
85
+ role: "tab",
86
+ ariaDisabled: this.tab.disabled,
87
+ ariaControls: this.idForContent,
88
+ ariaSelected: this.isActive,
89
+ tabindex: this.tabindexLocal,
90
+ onClick: this.onChangeTabLocal,
91
+ onKeydown: this.onKeydown,
92
+ }, [
93
+ this.tab.title && h("span", {
94
+ class: "a_position_absolute_all",
95
+ title: this.tab.title,
96
+ ariaHidden: true,
97
+ }),
98
+ h("span", {
99
+ innerHTML: this.tab.label,
100
+ })
101
+ ]),
102
+ ]);
103
+ },
104
+ };
@@ -0,0 +1,37 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import {
7
+ get,
8
+ } from "lodash-es";
9
+
10
+ export default function ATabAPI(props) {
11
+ const parentId = toRef(props, "parentId");
12
+ const index = toRef(props, "index");
13
+ const idLocal = computed(() => {
14
+ return `${ parentId.value }_${ index.value }`;
15
+ });
16
+
17
+ const idForContent = computed(() => {
18
+ return `${ idLocal.value }_content`;
19
+ });
20
+
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
+ return {
33
+ idForContent,
34
+ idLocal,
35
+ isActive,
36
+ };
37
+ }
@@ -17,14 +17,14 @@
17
17
  --a_dropdown_padding_y: 0.5rem;
18
18
  --bs-dropdown-spacer: 0.125rem;
19
19
  --a_dropdown_font_size: 1rem;
20
- --a_dropdown_color: var(--a_body_color);
20
+ --a_dropdown_color: var(--a_color_text);
21
21
  --a_dropdown_bg: #fff;
22
22
  --a_dropdown_border_color: var(--a_border_color);
23
23
  --a_dropdown_border_radius: var(--a_border_radius);
24
24
  --a_dropdown_border_width: var(--a_border_width);
25
25
  --a_dropdown_divider_color: var(--a_color_gray_500);
26
26
  --a_dropdown_divider_margin_y: 0.5rem;
27
- --a_dropdown_link_color: var(--a_body_color);
27
+ --a_dropdown_link_color: var(--a_color_text);
28
28
  --a_dropdown_link_hover_color: #1e2125;
29
29
  --a_dropdown_link_hover_bg: var(--a_color_gray_200);
30
30
  --a_dropdown_link_active_color: #fff;
@@ -0,0 +1,146 @@
1
+ .a_tabs {
2
+ --a_tabs_border_width: var(--a_border_width);
3
+ --a_tabs_border_color: var(--a_border_color);
4
+ --a_tabs_link_border_width: var(--a_border_width);
5
+ --a_tabs_link_border_color: transparent transparent var(--a_border_color) transparent;
6
+ --a_tabs_link_color: var(--a_color_text);
7
+ --a_tabs_link_bg: inherit;
8
+ --a_tabs_link_padding_x: 1rem;
9
+ --a_tabs_link_padding_y: .5rem;
10
+ --a_tabs_link_cursor: pointer;
11
+ --a_tabs_font_size: 1rem;
12
+ --a_tabs_border_radius: var(--a_border_radius);
13
+ --a_tabs_link_color_active: var(--a_color_primary);
14
+ --a_tabs_boxed_link_active_border_color: var(--a_border_color) var(--a_border_color) var(--a_color_white) var(--a_border_color);
15
+ --a_tabs_boxed_link_active_bg: var(--a_color_white);
16
+ --a_tabs_boxed_link_active_color: var(--a_color_primary);
17
+ // hover
18
+ --a_tabs_botom_hover_color: var(--a_color_gray_700);
19
+ --a_tabs_link_hover_color: var(--a_color_gray_900);
20
+ --a_tabs_focus_color: var(--a_color_focus);
21
+ --a_tabs_boxed_link_bg_hover: var(--a_color_gray_100);
22
+
23
+ // disabled
24
+ --a_tabs_link_disabled_cursor: default;
25
+ --a_tabs_link_disabled_border_color: transparent transparent var(--a_border_color) transparent;
26
+ --a_tabs_link_disabled_color: var(--a_color_gray_600);
27
+ --a_tabs_link_disabled_bg: inherit;
28
+
29
+ padding: .5rem;
30
+ }
31
+ .a_tabs_small {
32
+ --a_tabs_font_size: .75rem;
33
+ --a_tabs_link_padding_x: 0.75rem;
34
+ --a_tabs_link_padding_y: 0.375rem;
35
+ }
36
+ .a_tabs_medium {
37
+ --a_tabs_font_size: 1.25rem;
38
+ --a_tabs_link_padding_x: 1.25rem;
39
+ --a_tabs_link_padding_y: 0.625rem;
40
+ }
41
+ .a_tabs_large {
42
+ --a_tabs_font_size: 1.5rem;
43
+ --a_tabs_link_padding_x: 1.5rem;
44
+ --a_tabs_link_padding_y: 0.75rem;
45
+ }
46
+ .a_tabs__box {
47
+ align-items: stretch;
48
+ display: flex;
49
+ font-size: var(--a_tabs_font_size);
50
+ justify-content: space-between;
51
+ overflow: hidden;
52
+ overflow-x: auto;
53
+ white-space: nowrap;
54
+ }
55
+
56
+ .a_tabs__list {
57
+ list-style: none;
58
+ align-items: center;
59
+ border-bottom-color: var(--a_tabs_border_color);
60
+ border-bottom-style: solid;
61
+ border-bottom-width: var(--a_tabs_border_width);
62
+ display: flex;
63
+ flex-grow: 1;
64
+ flex-shrink: 0;
65
+ justify-content: flex-start;
66
+ padding: 0;
67
+ margin: 0;
68
+ }
69
+ .a_tabs__list__item {
70
+ display: block;
71
+ }
72
+ .a_tabs__list__link {
73
+ align-items: center;
74
+ border-width: var(--a_tabs_link_border_width);
75
+ border-color: var(--a_tabs_link_border_color);
76
+ border-style: solid;
77
+ color: var(--a_tabs_link_color);
78
+ display: flex;
79
+ justify-content: center;
80
+ margin-bottom: calc(-1 * var(--a_tabs_border_width));
81
+ padding: var(--a_tabs_link_padding_y) var(--a_tabs_link_padding_x);
82
+ vertical-align: top;
83
+ background-color: var(--a_tabs_link_bg);
84
+ position: relative;
85
+ cursor: var(--a_tabs_link_cursor);
86
+ border-radius: var(--a_tabs_border_radius) var(--a_tabs_border_radius) 0 0;
87
+ &:hover {
88
+ --a_tabs_link_border_color: transparent transparent var(--a_tabs_botom_hover_color) transparent;
89
+ --a_tabs_link_color: var(--a_tabs_link_hover_color);
90
+ }
91
+ &:focus {
92
+ box-shadow: inset 0 0 1px 3px var(--a_tabs_focus_color);
93
+ outline: none;
94
+ }
95
+ }
96
+ .a_tabs__list__link_active {
97
+ --a_tabs_link_border_color: transparent transparent var(--a_color_primary) transparent;
98
+ --a_tabs_link_color: var(--a_tabs_link_color_active);
99
+ z-index: 1;
100
+ &:hover {
101
+ --a_tabs_link_color: var(--a_tabs_link_color_active);
102
+ }
103
+ }
104
+
105
+ .a_tabs_boxed {
106
+
107
+ //.a_tabs__list__link {
108
+ // &:hover {
109
+ // --a_tabs_link_bg: var(--a_tabs_boxed_link_bg_hover);
110
+ // }
111
+ //
112
+ // //&:focus,
113
+ // //.a_tabs__list__item_active &:focus {
114
+ // //
115
+ // //}
116
+ //}
117
+ .a_tabs__list__link:hover {
118
+ --a_tabs_link_bg: var(--a_tabs_boxed_link_bg_hover);
119
+ }
120
+ .a_tabs__list__link_active {
121
+ --a_tabs_link_border_color: var(--a_tabs_boxed_link_active_border_color);
122
+ --a_tabs_link_bg: var(--a_tabs_boxed_link_active_bg);
123
+ }
124
+ }
125
+
126
+ .a_tabs {
127
+ & .a_tabs__list__link_disabled,
128
+ &.a_tabs_boxed .a_tabs__list__link_disabled {
129
+ --a_tabs_link_cursor: var(--a_tabs_link_disabled_cursor);
130
+ --a_tabs_link_border_color: var(--a_tabs_link_disabled_border_color);
131
+ --a_tabs_link_color: var(--a_tabs_link_disabled_color);
132
+ --a_tabs_link_bg: var(--a_tabs_link_disabled_bg);
133
+ box-shadow: none;
134
+ }
135
+ }
136
+ .a_tabs__contents {
137
+ border: var(--a_tabs_border_width) solid var(--a_tabs_border_color);
138
+ margin-top: -1px;
139
+ }
140
+ .a_tabs__content {
141
+ padding: var(--a_tabs_link_padding_y) var(--a_tabs_link_padding_x);
142
+ display: none;
143
+ }
144
+ .a_tabs__content_show {
145
+ display: block;
146
+ }
@@ -1,5 +1,10 @@
1
+ .a_search_highlight {
2
+ color: red;
3
+ }
4
+
1
5
  @import "components/AIcon";
2
6
  @import "components/ADropdown";
3
7
  @import "components/AResizer";
4
8
  @import "components/ui/ui";
5
9
  @import "components/ATable";
10
+ @import "components/ATabs";