@teammodlr/ui-kit 1.0.2
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/env.d.ts +1 -0
- package/lib/__storybook__/argTypes.d.ts +31 -0
- package/lib/__storybook__/createStory.d.ts +8 -0
- package/lib/__storybook__/index.d.ts +2 -0
- package/lib/components/avatar/Avatar.vue.d.ts +70 -0
- package/lib/components/avatargroup/AvatarGroup.vue.d.ts +34 -0
- package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +25 -0
- package/lib/components/breadcrumbitem/BreadcrumbItem.vue.d.ts +18 -0
- package/lib/components/breadcrumbitem/index.d.ts +1 -0
- package/lib/components/button/Button.vue.d.ts +121 -0
- package/lib/components/buttongroup/ButtonGroup.vue.d.ts +29 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +97 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +114 -0
- package/lib/components/dropdown/DropdownItem.vue.d.ts +61 -0
- package/lib/components/dropdown/DropdownList.vue.d.ts +2 -0
- package/lib/components/dropdown/DropdownWrapper.vue.d.ts +2 -0
- package/lib/components/dropdown/hooks.d.ts +2 -0
- package/lib/components/form/Form.vue.d.ts +67 -0
- package/lib/components/image/Image.vue.d.ts +50 -0
- package/lib/components/index.d.ts +26 -0
- package/lib/components/input/Input.vue.d.ts +126 -0
- package/lib/components/link/Link.vue.d.ts +51 -0
- package/lib/components/messageprovider/Message.vue.d.ts +61 -0
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +51 -0
- package/lib/components/messageprovider/types.d.ts +28 -0
- package/lib/components/messageprovider/useMessage.d.ts +2 -0
- package/lib/components/select/Select.vue.d.ts +180 -0
- package/lib/components/skeleton/Skeleton.vue.d.ts +39 -0
- package/lib/components/tab/Tab.vue.d.ts +41 -0
- package/lib/components/tab/TabGroup.vue.d.ts +43 -0
- package/lib/components/table/Table.vue.d.ts +63 -0
- package/lib/components/table/TableBody.vue.d.ts +2 -0
- package/lib/components/table/TableCell.vue.d.ts +2 -0
- package/lib/components/table/TableHead.vue.d.ts +20 -0
- package/lib/components/table/TableHeadRow.vue.d.ts +2 -0
- package/lib/components/table/TableRow.vue.d.ts +2 -0
- package/lib/components/table/types/index.d.ts +5 -0
- package/lib/components/tooltip/Tooltip.vue.d.ts +54 -0
- package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +43 -0
- package/lib/composables/element.d.ts +2 -0
- package/lib/composables/useCachedUid.d.ts +13 -0
- package/lib/composables/useEventListener.d.ts +1 -0
- package/lib/composables/useInput.d.ts +36 -0
- package/lib/composables/useIsServer.d.ts +1 -0
- package/lib/composables/useMount.d.ts +13 -0
- package/lib/composables/usePopper.d.ts +31 -0
- package/lib/create.d.ts +9 -0
- package/lib/index.cjs.js +5 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.es.js +3164 -0
- package/lib/install.d.ts +4 -0
- package/lib/nuxt.js +33 -0
- package/lib/nuxt.plugin.js +8 -0
- package/lib/style.css +1 -0
- package/lib/types/props.d.ts +2 -0
- package/package.json +75 -0
- package/src/__storybook__/argTypes.ts +42 -0
- package/src/__storybook__/createStory.ts +15 -0
- package/src/__storybook__/index.ts +2 -0
- package/src/components/avatar/Avatar.css +69 -0
- package/src/components/avatar/Avatar.vue +102 -0
- package/src/components/avatargroup/AvatarGroup.css +8 -0
- package/src/components/avatargroup/AvatarGroup.vue +32 -0
- package/src/components/breadcrumb/Breadcrumb.css +46 -0
- package/src/components/breadcrumb/Breadcrumb.vue +51 -0
- package/src/components/breadcrumbitem/BreadcrumbItem.vue +66 -0
- package/src/components/breadcrumbitem/index.ts +1 -0
- package/src/components/button/Button.css +378 -0
- package/src/components/button/Button.vue +108 -0
- package/src/components/buttongroup/ButtonGroup.vue +47 -0
- package/src/components/checkbox/Checkbox.css +185 -0
- package/src/components/checkbox/Checkbox.vue +140 -0
- package/src/components/dropdown/Dropdown.css +68 -0
- package/src/components/dropdown/Dropdown.vue +237 -0
- package/src/components/dropdown/DropdownItem.vue +118 -0
- package/src/components/dropdown/DropdownList.vue +20 -0
- package/src/components/dropdown/DropdownWrapper.vue +17 -0
- package/src/components/dropdown/hooks.ts +30 -0
- package/src/components/form/Form.vue +141 -0
- package/src/components/image/Image.vue +71 -0
- package/src/components/index.ts +27 -0
- package/src/components/input/Input.css +173 -0
- package/src/components/input/Input.vue +176 -0
- package/src/components/link/Link.css +147 -0
- package/src/components/link/Link.vue +54 -0
- package/src/components/messageprovider/Message.vue +76 -0
- package/src/components/messageprovider/MessageProvider.css +36 -0
- package/src/components/messageprovider/MessageProvider.vue +142 -0
- package/src/components/messageprovider/types.ts +39 -0
- package/src/components/messageprovider/useMessage.ts +12 -0
- package/src/components/select/Select.css +226 -0
- package/src/components/select/Select.vue +474 -0
- package/src/components/skeleton/Skeleton.css +73 -0
- package/src/components/skeleton/Skeleton.vue +47 -0
- package/src/components/tab/Tab.css +113 -0
- package/src/components/tab/Tab.vue +98 -0
- package/src/components/tab/TabGroup.vue +90 -0
- package/src/components/table/Table.css +45 -0
- package/src/components/table/Table.vue +108 -0
- package/src/components/table/TableBody.vue +13 -0
- package/src/components/table/TableCell.vue +13 -0
- package/src/components/table/TableHead.vue +22 -0
- package/src/components/table/TableHeadRow.vue +15 -0
- package/src/components/table/TableRow.vue +13 -0
- package/src/components/table/types/index.ts +5 -0
- package/src/components/tooltip/Tooltip.css +49 -0
- package/src/components/tooltip/Tooltip.vue +85 -0
- package/src/components/virtualscroll/VirtualScroll.css +13 -0
- package/src/components/virtualscroll/VirtualScroll.vue +61 -0
- package/src/composables/element.ts +13 -0
- package/src/composables/useCachedUid.ts +48 -0
- package/src/composables/useEventListener.ts +14 -0
- package/src/composables/useInput.ts +134 -0
- package/src/composables/useIsServer.ts +7 -0
- package/src/composables/useMount.ts +43 -0
- package/src/composables/usePopper.ts +194 -0
- package/src/create.ts +34 -0
- package/src/css/components.css +14 -0
- package/src/css/index.css +4 -0
- package/src/css/normalize.css +379 -0
- package/src/css/transitions.css +40 -0
- package/src/css/variables.css +80 -0
- package/src/exports/nuxt.js +33 -0
- package/src/exports/nuxt.plugin.js +8 -0
- package/src/index.ts +5 -0
- package/src/install.ts +8 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/types/props.ts +3 -0
- package/volar.d.ts +16 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.m-skeleton {
|
|
2
|
+
--skeleton-border-radius: 4px;
|
|
3
|
+
--skeleton-height: 100%;
|
|
4
|
+
--skeleton-width: 100%;
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
background: linear-gradient(-90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
|
|
8
|
+
background-size: 400% 400%;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
box-sizing: content-box;
|
|
15
|
+
border-radius: var(--skeleton-border-radius);
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
user-select: none;
|
|
18
|
+
width: var(--skeleton-width);
|
|
19
|
+
height: var(--skeleton-height);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.m-skeleton--thumb {
|
|
23
|
+
--skeleton-border-radius: 4px;
|
|
24
|
+
--skeleton-height: 128px;
|
|
25
|
+
--skeleton-width: 500px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.m-skeleton--heading {
|
|
29
|
+
--skeleton-border-radius: 4px;
|
|
30
|
+
--skeleton-height: 32px;
|
|
31
|
+
--skeleton-width: 500px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.m-skeleton--line {
|
|
35
|
+
--skeleton-border-radius: 4px;
|
|
36
|
+
--skeleton-height: 20px;
|
|
37
|
+
--skeleton-width: 500px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.m-skeleton--circle {
|
|
41
|
+
--skeleton-border-radius: 50%;
|
|
42
|
+
--skeleton-height: 40px;
|
|
43
|
+
--skeleton-width: 40px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.m-skeleton--block {
|
|
47
|
+
--skeleton-border-radius: 4px;
|
|
48
|
+
--skeleton-height: 100%;
|
|
49
|
+
--skeleton-width: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.m-skeleton--pulse {
|
|
53
|
+
animation: skeleton-pulse 1.5s ease-in-out infinite;
|
|
54
|
+
-webkit-animation: skeleton-pulse 1.5s ease-in-out infinite;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@keyframes skeleton-pulse {
|
|
58
|
+
0% {
|
|
59
|
+
background-position: 0 0;
|
|
60
|
+
}
|
|
61
|
+
100% {
|
|
62
|
+
background-position: -135% 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@-webkit-keyframes skeleton-pulse {
|
|
67
|
+
0% {
|
|
68
|
+
background-position: 0 0;
|
|
69
|
+
}
|
|
70
|
+
100% {
|
|
71
|
+
background-position: -135% 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="tag"
|
|
4
|
+
:class="computedClasses"
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
</component>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { computed, defineComponent } from 'vue';
|
|
12
|
+
|
|
13
|
+
export default defineComponent({
|
|
14
|
+
name: "MSkeleton",
|
|
15
|
+
props: {
|
|
16
|
+
tag: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "div"
|
|
19
|
+
},
|
|
20
|
+
variant: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "line",
|
|
23
|
+
validator: (value: string) => {
|
|
24
|
+
return ["block", "thumb", "heading", "line", "circle"].includes(value);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
animation: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "pulse"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setup(props) {
|
|
33
|
+
|
|
34
|
+
const computedClasses = computed(() => {
|
|
35
|
+
return {
|
|
36
|
+
"m-skeleton": true,
|
|
37
|
+
[`m-skeleton--${props.variant}`]: true,
|
|
38
|
+
[`m-skeleton--${props.animation}`]: true
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
computedClasses
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
.m-tab-group {
|
|
2
|
+
--tabs-gap: 14px;
|
|
3
|
+
--tabs-background: transparent;
|
|
4
|
+
--tabs-border-radius: 0;
|
|
5
|
+
--tabs-padding: 0;
|
|
6
|
+
--tabs-border: 1px solid var(--gray-200);
|
|
7
|
+
|
|
8
|
+
--tab-background: var(transparent);
|
|
9
|
+
--tab-color: var(--gray-600);
|
|
10
|
+
--tab-font-size: 15px;
|
|
11
|
+
--tab-padding: 12px 8px;
|
|
12
|
+
--tab-border-radius: 0px;
|
|
13
|
+
--tab-font-weight: 500;
|
|
14
|
+
--tab-box-shadow: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.m-tab-group__tabs {
|
|
18
|
+
background: var(--tabs-background);
|
|
19
|
+
border-radius: var(--tabs-border-radius);
|
|
20
|
+
position: relative;
|
|
21
|
+
border-bottom: var(--tabs-border);
|
|
22
|
+
display: flex;
|
|
23
|
+
min-width: 100%;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
list-style: none;
|
|
26
|
+
padding: var(--tabs-padding);
|
|
27
|
+
margin: 0;
|
|
28
|
+
gap: var(--tabs-gap);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.m-tab-group__tabs .m-tab {
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.m-tab-group__tabs .m-tab .m-tabs__button {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
font-size: var(--tab-font-size);
|
|
40
|
+
font-weight: var(--tab-font-weight);
|
|
41
|
+
color: var(--tab-color);
|
|
42
|
+
background-color: var(--tab-background);
|
|
43
|
+
padding: var(--tab-padding);
|
|
44
|
+
border-radius: var(--tab-border-radius);
|
|
45
|
+
box-shadow: var(--tab-box-shadow);
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: all 0.2s ease-in-out;
|
|
48
|
+
border: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.m-tab-group__tabs .m-tab:not(.m-tab--disabled) .m-tabs__button:hover {
|
|
52
|
+
--tab-background: var(transparent);
|
|
53
|
+
--tab-color: var(--blue);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.m-tab-group__tabs .m-tab.m-tab--active .m-tabs__button {
|
|
57
|
+
--tab-background: var(--white);
|
|
58
|
+
--tab-color: var(--blue);
|
|
59
|
+
--tab-box-shadow: inset 0px -2px 0px var(--blue);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.m-tab-group__tabs .m-tab.m-tab--disabled .m-tabs__button {
|
|
63
|
+
--tab-color: var(--gray-400);
|
|
64
|
+
cursor: not-allowed;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.m-tab-group.m-tab-group--xs {
|
|
68
|
+
--tabs-background: transparent;
|
|
69
|
+
--tabs-border-radius: 0;
|
|
70
|
+
--tabs-padding: 0;
|
|
71
|
+
--tabs-gap: 8px;
|
|
72
|
+
|
|
73
|
+
--tab-font-size: 12px;
|
|
74
|
+
--tab-padding: 10px 6px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.m-tab-group.m-tab-group--sm {
|
|
78
|
+
--tabs-background: transparent;
|
|
79
|
+
--tabs-border-radius: 0;
|
|
80
|
+
--tabs-padding: 0;
|
|
81
|
+
--tabs-gap: 10px;
|
|
82
|
+
|
|
83
|
+
--tab-font-size: 13px;
|
|
84
|
+
--tab-padding: 13px 6px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.m-tab-group.m-tab-group--lg {
|
|
88
|
+
--tabs-background: transparent;
|
|
89
|
+
--tabs-border-radius: 0;
|
|
90
|
+
--tabs-padding: 0;
|
|
91
|
+
|
|
92
|
+
--tab-font-size: 16px;
|
|
93
|
+
--tab-padding: 20px 12px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.m-tab-group.m-tab-group--xl {
|
|
97
|
+
--tabs-background: transparent;
|
|
98
|
+
--tabs-border-radius: 0;
|
|
99
|
+
--tabs-padding: 0;
|
|
100
|
+
|
|
101
|
+
--tab-font-size: 18px;
|
|
102
|
+
--tab-padding: 24px 16px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.m-tab-group.m-tab-group--vertical {
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.m-tab-group.m-tab-group--vertical .m-tab-group__tabs {
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: 0;
|
|
112
|
+
width: 200px;
|
|
113
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li
|
|
3
|
+
:data-value="computedValue"
|
|
4
|
+
:class="computedTabWrapperClasses"
|
|
5
|
+
>
|
|
6
|
+
<button
|
|
7
|
+
role="button"
|
|
8
|
+
type="button"
|
|
9
|
+
ref="tabRef"
|
|
10
|
+
:class="computedTabClasses"
|
|
11
|
+
@click.prevent="handleClick"
|
|
12
|
+
:disabled="disabled"
|
|
13
|
+
>
|
|
14
|
+
<slot
|
|
15
|
+
name="tab"
|
|
16
|
+
:label="label"
|
|
17
|
+
:value="value"
|
|
18
|
+
>
|
|
19
|
+
{{ computedLabel }}
|
|
20
|
+
</slot>
|
|
21
|
+
|
|
22
|
+
<teleport v-if="selected && teleportTo" :to="teleportTo">
|
|
23
|
+
<slot />
|
|
24
|
+
</teleport>
|
|
25
|
+
</button>
|
|
26
|
+
</li>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import { computed, defineComponent, inject, onMounted, reactive, ref } from 'vue';
|
|
31
|
+
|
|
32
|
+
export default defineComponent({
|
|
33
|
+
name: "Tab",
|
|
34
|
+
props: {
|
|
35
|
+
value: {
|
|
36
|
+
type: [String, Number]
|
|
37
|
+
},
|
|
38
|
+
label: {
|
|
39
|
+
type: String,
|
|
40
|
+
},
|
|
41
|
+
disabled: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
setup(props, { emit }) {
|
|
47
|
+
const computedValue = computed(() => props.value);
|
|
48
|
+
const computedLabel = computed(() => props.label || props.value);
|
|
49
|
+
const tabRef = ref<HTMLElement | null>(null);
|
|
50
|
+
const teleportTo = ref(null);
|
|
51
|
+
|
|
52
|
+
const tabs = inject("tabs", {
|
|
53
|
+
tabsContentRef: ref(null),
|
|
54
|
+
selectTab: (tab: string | number) => {},
|
|
55
|
+
state: reactive({
|
|
56
|
+
active: ""
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const computedTabWrapperClasses = computed(() => {
|
|
61
|
+
return {
|
|
62
|
+
'm-tab': true,
|
|
63
|
+
'm-tab--active': selected.value,
|
|
64
|
+
'm-tab--disabled': props.disabled
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const computedTabClasses = computed(() => {
|
|
69
|
+
return {
|
|
70
|
+
'm-tabs__button': true,
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const selected = computed(() => {
|
|
75
|
+
return tabs.state.active === computedValue.value;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
function handleClick() {
|
|
79
|
+
tabs.selectTab(computedValue.value!);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onMounted(() => {
|
|
83
|
+
teleportTo.value = tabs.tabsContentRef.value;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
computedValue,
|
|
88
|
+
computedLabel,
|
|
89
|
+
tabRef,
|
|
90
|
+
computedTabWrapperClasses,
|
|
91
|
+
computedTabClasses,
|
|
92
|
+
handleClick,
|
|
93
|
+
selected,
|
|
94
|
+
teleportTo
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
</script>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="computedWrapperClasses"
|
|
4
|
+
>
|
|
5
|
+
<div
|
|
6
|
+
ref="wrapperRef"
|
|
7
|
+
|
|
8
|
+
>
|
|
9
|
+
<ul
|
|
10
|
+
ref="tabsRef"
|
|
11
|
+
:class="computedTabsClasses"
|
|
12
|
+
>
|
|
13
|
+
<slot />
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
16
|
+
<div ref="tabsContentRef" class="m-tab-group__content"></div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import type { Size } from '@/types/props';
|
|
22
|
+
import { computed, defineComponent, provide, reactive, ref, watchEffect, type PropType } from 'vue';
|
|
23
|
+
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
name: "TabGroup",
|
|
26
|
+
props: {
|
|
27
|
+
modelValue: {
|
|
28
|
+
type: [String, Number],
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
type: String as PropType<Size>,
|
|
32
|
+
default: 'md'
|
|
33
|
+
},
|
|
34
|
+
vertical: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
emit: [
|
|
40
|
+
'update:modelValue'
|
|
41
|
+
],
|
|
42
|
+
setup(props, { emit }) {
|
|
43
|
+
const wrapperRef = ref<HTMLElement>();
|
|
44
|
+
const tabsContentRef = ref<HTMLElement>();
|
|
45
|
+
const contentRef = ref<HTMLElement>();
|
|
46
|
+
const active = ref();
|
|
47
|
+
|
|
48
|
+
watchEffect(() => {
|
|
49
|
+
active.value = props.modelValue;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const state = reactive({
|
|
53
|
+
active: computed(() => active.value)
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const computedWrapperClasses = computed(() => {
|
|
57
|
+
return {
|
|
58
|
+
'm-tab-group': true,
|
|
59
|
+
'm-tab-group--vertical': props.vertical,
|
|
60
|
+
[`m-tab-group--${props.size}`]: true
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const computedTabsClasses = computed(() => {
|
|
65
|
+
return {
|
|
66
|
+
'm-tab-group__tabs': true,
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
function selectTab(tab: string | number) {
|
|
71
|
+
active.value = tab;
|
|
72
|
+
emit('update:modelValue', tab);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
provide("tabs", {
|
|
76
|
+
tabsContentRef,
|
|
77
|
+
selectTab,
|
|
78
|
+
state
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
wrapperRef,
|
|
83
|
+
tabsContentRef,
|
|
84
|
+
contentRef,
|
|
85
|
+
computedWrapperClasses,
|
|
86
|
+
computedTabsClasses
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.m-table__wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
overflow-x: auto;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.m-table {
|
|
7
|
+
--table-cell-padding: 10px 15px;
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.m-table thead tr {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.m-table thead tr th {
|
|
17
|
+
padding: var(--table-cell-padding);
|
|
18
|
+
text-align: left;
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
background-color: var(--gray-150);
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
color: var(--gray-700);
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
line-height: 15px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.m-table tbody tr:first-child td {
|
|
28
|
+
border-top: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.m-table tbody tr td {
|
|
32
|
+
padding: var(--table-cell-padding);
|
|
33
|
+
border-top: 1px solid var(--gray-150);
|
|
34
|
+
font-size: 15px;
|
|
35
|
+
line-height: 15px;
|
|
36
|
+
vertical-align: middle;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.m-table.m-table--striped tbody tr:nth-child(even) td {
|
|
40
|
+
background-color: var(--gray-50);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.m-table.m-table--hover tbody tr:hover td {
|
|
44
|
+
background-color: var(--gray-50);
|
|
45
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="wrapperComputedClasses"
|
|
4
|
+
>
|
|
5
|
+
<table
|
|
6
|
+
:class="tableComputedClasses"
|
|
7
|
+
>
|
|
8
|
+
<TableHeadRow>
|
|
9
|
+
<TableHead
|
|
10
|
+
v-for="(header, index) in headers"
|
|
11
|
+
:key="index"
|
|
12
|
+
:width="header.width"
|
|
13
|
+
>
|
|
14
|
+
{{ header.name }}
|
|
15
|
+
</TableHead>
|
|
16
|
+
</TableHeadRow>
|
|
17
|
+
<TableBody>
|
|
18
|
+
<TableRow
|
|
19
|
+
v-for="(item, index) in items"
|
|
20
|
+
:key="index"
|
|
21
|
+
>
|
|
22
|
+
<TableCell
|
|
23
|
+
v-for="(header, index) in headers"
|
|
24
|
+
:key="index"
|
|
25
|
+
>
|
|
26
|
+
<slot :name="header.key" :item="item">
|
|
27
|
+
{{//@ts-ignore
|
|
28
|
+
item[header.key] }}
|
|
29
|
+
</slot>
|
|
30
|
+
</TableCell>
|
|
31
|
+
</TableRow>
|
|
32
|
+
</TableBody>
|
|
33
|
+
</table>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script lang="ts">
|
|
38
|
+
import { computed, defineComponent, type PropType } from 'vue';
|
|
39
|
+
import type { TableHeadItem } from './types';
|
|
40
|
+
import TableHeadRow from './TableHeadRow.vue';
|
|
41
|
+
import TableHead from './TableHead.vue';
|
|
42
|
+
import TableBody from './TableBody.vue';
|
|
43
|
+
import TableRow from './TableRow.vue';
|
|
44
|
+
import TableCell from './TableCell.vue';
|
|
45
|
+
|
|
46
|
+
export default defineComponent({
|
|
47
|
+
name: "Table",
|
|
48
|
+
components: {
|
|
49
|
+
TableHeadRow,
|
|
50
|
+
TableHead,
|
|
51
|
+
TableBody,
|
|
52
|
+
TableRow,
|
|
53
|
+
TableCell
|
|
54
|
+
},
|
|
55
|
+
emits: [
|
|
56
|
+
'update:sort',
|
|
57
|
+
],
|
|
58
|
+
props: {
|
|
59
|
+
headers: {
|
|
60
|
+
type: Array as PropType<Array<TableHeadItem>>,
|
|
61
|
+
default: () => [],
|
|
62
|
+
},
|
|
63
|
+
items: {
|
|
64
|
+
type: Array,
|
|
65
|
+
default: () => []
|
|
66
|
+
},
|
|
67
|
+
loading: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
striped: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
hover: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
setup(props) {
|
|
81
|
+
|
|
82
|
+
const wrapperComputedClasses = computed(() => {
|
|
83
|
+
return [
|
|
84
|
+
'm-table__wrapper',
|
|
85
|
+
{
|
|
86
|
+
'm-table__wrapper--loading': props.loading
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const tableComputedClasses = computed(() => {
|
|
92
|
+
return [
|
|
93
|
+
'm-table',
|
|
94
|
+
{
|
|
95
|
+
'm-table--loading': props.loading,
|
|
96
|
+
'm-table--striped': props.striped,
|
|
97
|
+
'm-table--hover': props.hover
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
wrapperComputedClasses,
|
|
104
|
+
tableComputedClasses
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<th>
|
|
3
|
+
<slot />
|
|
4
|
+
</th>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { defineComponent } from "vue";
|
|
9
|
+
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: "TableHead",
|
|
12
|
+
props: {
|
|
13
|
+
sort: {
|
|
14
|
+
type: Number
|
|
15
|
+
},
|
|
16
|
+
sortable: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
</script>
|