@teammodlr/ui-kit 1.0.7 → 2.0.1
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/lib/__storybook__/argTypes.d.ts +10 -1
- package/lib/components/avatar/Avatar.vue.d.ts +16 -30
- package/lib/components/avatar/style/Avatar.css.d.ts +9 -0
- package/lib/components/avatar/style/index.d.ts +1 -0
- package/lib/components/avatargroup/AvatarGroup.vue.d.ts +28 -13
- package/lib/components/avatargroup/style/AvatarGroup.css.d.ts +2 -0
- package/lib/components/avatargroup/style/index.d.ts +1 -0
- package/lib/components/avatargroup/symbol.d.ts +13 -0
- package/lib/components/badge/Badge.vue.d.ts +30 -0
- package/lib/components/badge/style/Badge.css.d.ts +4 -0
- package/lib/components/badge/style/index.d.ts +1 -0
- package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +12 -3
- package/lib/components/{breadcrumbitem → breadcrumb}/BreadcrumbItem.vue.d.ts +11 -0
- package/lib/components/breadcrumb/style/Breadcrumb.css.d.ts +4 -0
- package/lib/components/breadcrumb/style/index.d.ts +1 -0
- package/lib/components/breadcrumb/symbol.d.ts +13 -0
- package/lib/components/button/Button.vue.d.ts +39 -28
- package/lib/components/button/style/Button.css.d.ts +24 -0
- package/lib/components/button/style/index.d.ts +1 -0
- package/lib/components/buttongroup/ButtonGroup.vue.d.ts +2 -13
- package/lib/components/buttongroup/style/ButtonGroup.css.d.ts +2 -0
- package/lib/components/buttongroup/style/index.d.ts +1 -0
- package/lib/components/buttongroup/symbol.d.ts +6 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +17 -20
- package/lib/components/checkbox/style/Checkbox.css.d.ts +16 -0
- package/lib/components/checkbox/style/index.d.ts +1 -0
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +75 -0
- package/lib/components/colorpicker/style/ColorPicker.css.d.ts +9 -0
- package/lib/components/colorpicker/style/index.d.ts +1 -0
- package/lib/components/colorpicker/utils.d.ts +16 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +5 -4
- package/lib/components/dropdown/DropdownItem.vue.d.ts +12 -5
- package/lib/components/dropdown/DropdownList.vue.d.ts +4 -1
- package/lib/components/dropdown/style/Dropdown.css.d.ts +5 -0
- package/lib/components/dropdown/style/index.d.ts +1 -0
- package/lib/components/dropdown/symbol.d.ts +6 -0
- package/lib/components/form/Form.vue.d.ts +12 -1
- package/lib/components/form/style/Form.css.d.ts +4 -0
- package/lib/components/form/style/index.d.ts +2 -0
- package/lib/components/index.d.ts +10 -1
- package/lib/components/input/Input.vue.d.ts +35 -19
- package/lib/components/input/style/Input.css.d.ts +23 -0
- package/lib/components/input/style/index.d.ts +1 -0
- package/lib/components/link/Link.vue.d.ts +2 -2
- package/lib/components/messageprovider/Message.vue.d.ts +13 -1
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +6 -5
- package/lib/components/messageprovider/style/Message.css.d.ts +12 -0
- package/lib/components/messageprovider/style/index.d.ts +1 -0
- package/lib/components/messageprovider/types.d.ts +2 -1
- package/lib/components/modal/Modal.vue.d.ts +52 -0
- package/lib/components/modal/style/Modal.css.d.ts +21 -0
- package/lib/components/modal/style/index.d.ts +1 -0
- package/lib/components/radio/Radio.vue.d.ts +85 -0
- package/lib/components/radio/style/Checkbox.css.d.ts +16 -0
- package/lib/components/radio/style/index.d.ts +1 -0
- package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -0
- package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -0
- package/lib/components/radiobutton/style/index.d.ts +1 -0
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -0
- package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -0
- package/lib/components/radiobuttongroup/style/index.d.ts +1 -0
- package/lib/components/radiobuttongroup/symbol.d.ts +9 -0
- package/lib/components/select/Select.vue.d.ts +22 -13
- package/lib/components/select/style/Select.css.d.ts +30 -0
- package/lib/components/select/style/index.d.ts +1 -0
- package/lib/components/skeleton/Skeleton.vue.d.ts +15 -21
- package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -0
- package/lib/components/skeleton/style/index.d.ts +2 -0
- package/lib/components/slider/Slider.vue.d.ts +32 -0
- package/lib/components/slider/style/Slider.css.d.ts +4 -0
- package/lib/components/slider/style/index.d.ts +1 -0
- package/lib/components/tab/TabGroup.vue.d.ts +1 -1
- package/lib/components/table/Table.vue.d.ts +1 -1
- package/lib/components/tag/Tag.vue.d.ts +44 -0
- package/lib/components/tag/style/Tag.css.d.ts +11 -0
- package/lib/components/tag/style/index.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.vue.d.ts +17 -2
- package/lib/components/tooltip/style/Tooltip.css.d.ts +6 -0
- package/lib/components/tooltip/style/index.d.ts +1 -0
- package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +46 -16
- package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -0
- package/lib/components/virtualscroll/style/index.d.ts +1 -0
- package/lib/composables/useInput.d.ts +1 -1
- package/lib/composables/useInteractive.d.ts +15 -0
- package/lib/composables/useZIndex.d.ts +8 -0
- package/lib/index.cjs.js +8 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.es.js +3699 -1694
- package/lib/style.css +1 -1
- package/lib/styles/theme.css.d.ts +147 -0
- package/lib/styles/typography.css.d.ts +22 -0
- package/lib/types/props.d.ts +1 -0
- package/package.json +34 -26
- package/src/__storybook__/argTypes.ts +19 -1
- package/src/components/avatar/Avatar.vue +33 -26
- package/src/components/avatar/examples/index.stories.ts +1 -1
- package/src/components/avatar/style/Avatar.css.ts +92 -0
- package/src/components/avatar/style/index.ts +1 -0
- package/src/components/avatargroup/AvatarGroup.vue +71 -32
- package/src/components/avatargroup/examples/basic.vue +33 -7
- package/src/components/avatargroup/examples/index.stories.ts +4 -8
- package/src/components/avatargroup/style/AvatarGroup.css.ts +21 -0
- package/src/components/avatargroup/style/index.ts +1 -0
- package/src/components/avatargroup/symbol.ts +17 -0
- package/src/components/badge/Badge.css +128 -0
- package/src/components/badge/Badge.vue +43 -0
- package/src/components/badge/examples/basic.vue +10 -0
- package/src/components/badge/examples/index.stories.ts +21 -0
- package/src/components/badge/examples/index.ts +1 -0
- package/src/components/badge/style/Badge.css.ts +124 -0
- package/src/components/badge/style/index.ts +1 -0
- package/src/components/breadcrumb/Breadcrumb.vue +22 -15
- package/src/components/breadcrumb/BreadcrumbItem.vue +73 -0
- package/src/components/breadcrumb/examples/basic.vue +5 -7
- package/src/components/breadcrumb/examples/index.stories.ts +2 -2
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -0
- package/src/components/breadcrumb/style/index.ts +1 -0
- package/src/components/breadcrumb/symbol.ts +17 -0
- package/src/components/button/Button.vue +194 -107
- package/src/components/button/examples/icon-left.vue +12 -0
- package/src/components/button/examples/icon.vue +6 -7
- package/src/components/button/examples/index.stories.ts +9 -7
- package/src/components/button/examples/index.ts +3 -2
- package/src/components/button/examples/variants-secondary.vue +8 -0
- package/src/components/button/examples/variants.vue +8 -0
- package/src/components/button/style/Button.css.ts +585 -0
- package/src/components/button/style/index.ts +1 -0
- package/src/components/buttongroup/ButtonGroup.vue +36 -47
- package/src/components/buttongroup/examples/basic.vue +2 -2
- package/src/components/buttongroup/examples/icon-group.vue +22 -0
- package/src/components/buttongroup/examples/index.stories.ts +4 -2
- package/src/components/buttongroup/examples/index.ts +1 -0
- package/src/components/buttongroup/style/ButtonGroup.css.ts +40 -0
- package/src/components/buttongroup/style/index.ts +1 -0
- package/src/components/buttongroup/symbol.ts +8 -0
- package/src/components/checkbox/Checkbox.vue +70 -54
- package/src/components/checkbox/examples/index.stories.ts +1 -1
- package/src/components/checkbox/style/Checkbox.css.ts +127 -0
- package/src/components/checkbox/style/index.ts +1 -0
- package/src/components/colorpicker/ColorPicker.vue +283 -0
- package/src/components/colorpicker/examples/basic.vue +3 -0
- package/src/components/colorpicker/examples/index.stories.ts +17 -0
- package/src/components/colorpicker/examples/index.ts +1 -0
- package/src/components/colorpicker/style/ColorPicker.css.ts +97 -0
- package/src/components/colorpicker/style/index.ts +1 -0
- package/src/components/colorpicker/utils.ts +188 -0
- package/src/components/dropdown/Dropdown.vue +45 -24
- package/src/components/dropdown/DropdownItem.vue +121 -118
- package/src/components/dropdown/DropdownList.vue +3 -3
- package/src/components/dropdown/DropdownWrapper.vue +2 -1
- package/src/components/dropdown/examples/custom.vue +13 -0
- package/src/components/dropdown/examples/index.stories.ts +4 -2
- package/src/components/dropdown/examples/index.ts +1 -0
- package/src/components/dropdown/style/Dropdown.css.ts +48 -0
- package/src/components/dropdown/style/index.ts +1 -0
- package/src/components/dropdown/symbol.ts +8 -0
- package/src/components/form/Form.vue +12 -3
- package/src/components/form/examples/basic.vue +4 -2
- package/src/components/form/examples/index.stories.ts +4 -2
- package/src/components/form/style/Form.css.ts +23 -0
- package/src/components/form/style/index.ts +2 -0
- package/src/components/image/examples/index.stories.ts +1 -1
- package/src/components/index.ts +10 -2
- package/src/components/input/Input.vue +84 -42
- package/src/components/input/examples/basic.vue +2 -1
- package/src/components/input/examples/index.stories.ts +1 -1
- package/src/components/input/examples/prefix.vue +4 -2
- package/src/components/input/examples/suffix.vue +4 -2
- package/src/components/input/style/Input.css.ts +221 -0
- package/src/components/input/style/index.ts +1 -0
- package/src/components/link/examples/index.stories.ts +1 -1
- package/src/components/messageprovider/Message.vue +52 -5
- package/src/components/messageprovider/MessageProvider.css +0 -13
- package/src/components/messageprovider/MessageProvider.vue +18 -16
- package/src/components/messageprovider/examples/basic.vue +56 -5
- package/src/components/messageprovider/examples/index.stories.ts +0 -1
- package/src/components/messageprovider/examples/index.ts +1 -0
- package/src/components/messageprovider/examples/update.vue +34 -0
- package/src/components/messageprovider/examples/wrapper.vue +1 -1
- package/src/components/messageprovider/style/Message.css.ts +109 -0
- package/src/components/messageprovider/style/index.ts +1 -0
- package/src/components/messageprovider/types.ts +9 -1
- package/src/components/modal/Modal.vue +126 -0
- package/src/components/modal/examples/basic.vue +40 -0
- package/src/components/modal/examples/index.stories.ts +20 -0
- package/src/components/modal/examples/index.ts +2 -0
- package/src/components/modal/examples/modal-form.vue +99 -0
- package/src/components/modal/style/Modal.css.ts +257 -0
- package/src/components/modal/style/index.ts +1 -0
- package/src/components/radio/Checkbox.css +185 -0
- package/src/components/radio/Radio.vue +137 -0
- package/src/components/radio/examples/basic.vue +9 -0
- package/src/components/radio/examples/index.stories.ts +19 -0
- package/src/components/radio/examples/index.ts +2 -0
- package/src/components/radio/style/Checkbox.css.ts +132 -0
- package/src/components/radio/style/index.ts +1 -0
- package/src/components/radiobutton/RadioButton.vue +131 -0
- package/src/components/radiobutton/style/RadioButton.css.ts +185 -0
- package/src/components/radiobutton/style/index.ts +1 -0
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +75 -0
- package/src/components/radiobuttongroup/examples/basic.vue +17 -0
- package/src/components/radiobuttongroup/examples/index.stories.ts +22 -0
- package/src/components/radiobuttongroup/examples/index.ts +2 -0
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -0
- package/src/components/radiobuttongroup/style/index.ts +1 -0
- package/src/components/radiobuttongroup/symbol.ts +11 -0
- package/src/components/select/Select.css +0 -226
- package/src/components/select/Select.vue +116 -48
- package/src/components/select/examples/index.stories.ts +1 -1
- package/src/components/select/examples/multiple.vue +1 -2
- package/src/components/select/style/Select.css.ts +254 -0
- package/src/components/select/style/index.ts +1 -0
- package/src/components/skeleton/Skeleton.vue +55 -47
- package/src/components/skeleton/examples/index.stories.ts +1 -8
- package/src/components/skeleton/style/Skeleton.css.ts +57 -0
- package/src/components/skeleton/style/index.ts +2 -0
- package/src/components/slider/Slider.vue +76 -0
- package/src/components/slider/style/Slider.css.ts +43 -0
- package/src/components/slider/style/index.ts +1 -0
- package/src/components/tab/examples/index.stories.ts +1 -1
- package/src/components/table/examples/index.stories.ts +1 -1
- package/src/components/tag/Tag.css +0 -0
- package/src/components/tag/Tag.vue +66 -0
- package/src/components/tag/examples/basic.vue +5 -0
- package/src/components/tag/examples/index.stories.ts +22 -0
- package/src/components/tag/examples/index.ts +1 -0
- package/src/components/tag/style/Tag.css.ts +79 -0
- package/src/components/tag/style/index.ts +1 -0
- package/src/components/tooltip/Tooltip.css +0 -6
- package/src/components/tooltip/Tooltip.vue +53 -22
- package/src/components/tooltip/examples/basic.vue +2 -5
- package/src/components/tooltip/examples/index.stories.ts +1 -1
- package/src/components/tooltip/style/Tooltip.css.ts +48 -0
- package/src/components/tooltip/style/index.ts +1 -0
- package/src/components/virtualscroll/VirtualScroll.vue +159 -53
- package/src/components/virtualscroll/examples/basic.vue +21 -27
- package/src/components/virtualscroll/examples/index.stories.ts +2 -18
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +18 -0
- package/src/components/virtualscroll/style/index.ts +1 -0
- package/src/composables/useInput.ts +2 -2
- package/src/composables/useInteractive.ts +20 -0
- package/src/composables/usePopper.ts +1 -1
- package/src/composables/useZIndex.ts +31 -0
- package/src/css/components.css +4 -3
- package/src/css/normalize.css +0 -379
- package/src/css/variables.css +2 -2
- package/src/examples/cards/cards.stories.ts +9 -0
- package/src/examples/cards/sidebar.vue +263 -0
- package/src/index.ts +1 -1
- package/src/styles/theme.css.ts +149 -0
- package/src/styles/typography.css.ts +91 -0
- package/src/types/props.ts +2 -0
- package/lib/components/breadcrumbitem/index.d.ts +0 -1
- package/src/components/avatar/Avatar.css +0 -69
- package/src/components/breadcrumbitem/BreadcrumbItem.vue +0 -66
- package/src/components/breadcrumbitem/index.ts +0 -1
- package/src/components/button/examples/colors-secondary.vue +0 -8
- package/src/components/button/examples/colors.vue +0 -8
- package/src/components/dropdown/Dropdown.css +0 -68
- /package/src/components/button/{Button.css → Button-old.css} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createVar, globalStyle, style, styleVariants } from "@vanilla-extract/css";
|
|
2
|
+
import { themeVars } from "../../../styles/theme.css";
|
|
3
|
+
import { fonts } from "../../../styles/typography.css";
|
|
4
|
+
|
|
5
|
+
const sizes = {
|
|
6
|
+
xs: '18px',
|
|
7
|
+
sm: '22px',
|
|
8
|
+
md: '26px',
|
|
9
|
+
lg: '30px',
|
|
10
|
+
xl: '34px',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const borderRadiuses = {
|
|
14
|
+
xs: '2px',
|
|
15
|
+
sm: '3px',
|
|
16
|
+
md: '4px',
|
|
17
|
+
lg: '6px',
|
|
18
|
+
xl: '8px',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const vars = {
|
|
22
|
+
height: createVar(),
|
|
23
|
+
radius: createVar(),
|
|
24
|
+
paddingX: createVar(),
|
|
25
|
+
paddingY: createVar(),
|
|
26
|
+
borderColor: createVar(),
|
|
27
|
+
backgroundColor: createVar(),
|
|
28
|
+
color: createVar(),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const base = style({
|
|
32
|
+
vars: {
|
|
33
|
+
[vars.height]: sizes.md,
|
|
34
|
+
[vars.radius]: borderRadiuses.md,
|
|
35
|
+
[vars.paddingX]: themeVars.space[1.5],
|
|
36
|
+
[vars.paddingY]: themeVars.space[0],
|
|
37
|
+
[vars.borderColor]: themeVars.color.gray[100],
|
|
38
|
+
[vars.color]: themeVars.color.gray[700],
|
|
39
|
+
[vars.backgroundColor]: themeVars.color.gray[100],
|
|
40
|
+
},
|
|
41
|
+
height: vars.height,
|
|
42
|
+
minHeight: vars.height,
|
|
43
|
+
lineHeight: vars.height,
|
|
44
|
+
borderRadius: vars.radius,
|
|
45
|
+
borderWidth: 1,
|
|
46
|
+
borderStyle: 'solid',
|
|
47
|
+
color: vars.color,
|
|
48
|
+
borderColor: vars.borderColor,
|
|
49
|
+
backgroundColor: vars.backgroundColor,
|
|
50
|
+
padding: `${vars.paddingY} ${vars.paddingX}`,
|
|
51
|
+
wordBreak: 'break-word',
|
|
52
|
+
fontSize: themeVars.fontSize.base,
|
|
53
|
+
display: 'inline-flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const close = style({
|
|
58
|
+
marginLeft: themeVars.space[1],
|
|
59
|
+
appearance: 'none',
|
|
60
|
+
outline: 'none',
|
|
61
|
+
border: 'none',
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
cursor: 'pointer',
|
|
66
|
+
backgroundColor: 'transparent',
|
|
67
|
+
padding: '3px',
|
|
68
|
+
position: 'relative',
|
|
69
|
+
right: '-2px',
|
|
70
|
+
color: themeVars.color.gray[500],
|
|
71
|
+
borderRadius: '50%',
|
|
72
|
+
':hover': {
|
|
73
|
+
backgroundColor: themeVars.color.gray[200],
|
|
74
|
+
color: themeVars.color.gray[700],
|
|
75
|
+
},
|
|
76
|
+
':focus': {
|
|
77
|
+
outline: 'none'
|
|
78
|
+
}
|
|
79
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tag.css';
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<span
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
@mouseenter="() => { isOpen = true }"
|
|
5
|
+
@mouseleave="() => { isOpen = false }"
|
|
6
|
+
ref="wrapper"
|
|
7
|
+
>
|
|
8
|
+
<span ref="reference">
|
|
9
|
+
<slot />
|
|
10
|
+
</span>
|
|
11
|
+
|
|
12
|
+
<Teleport :to="transferTo">
|
|
13
|
+
<div role="tooltip" :class="computedClasses" ref="popper" v-if="isOpen" :style="{zIndex: zIndex}">
|
|
14
|
+
<slot
|
|
15
|
+
:text="text"
|
|
16
|
+
name="content"
|
|
17
|
+
>
|
|
18
|
+
{{ text }}
|
|
19
|
+
</slot>
|
|
20
|
+
</div>
|
|
12
21
|
</Teleport>
|
|
13
22
|
</span>
|
|
14
23
|
</template>
|
|
@@ -16,10 +25,16 @@
|
|
|
16
25
|
<script lang="ts">
|
|
17
26
|
import { defineComponent, ref, toRef, type PropType, computed, watch } from 'vue';
|
|
18
27
|
import { type Placement, placementWhileList, usePopper } from "../../composables/usePopper";
|
|
28
|
+
import * as style from "./style";
|
|
29
|
+
import {useZIndex} from "../../composables/useZIndex";
|
|
19
30
|
|
|
20
31
|
export default defineComponent({
|
|
21
32
|
name: "MTooltip",
|
|
22
33
|
props: {
|
|
34
|
+
text: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
23
38
|
placement: {
|
|
24
39
|
type: String as PropType<Placement>,
|
|
25
40
|
default: 'top',
|
|
@@ -36,37 +51,53 @@ export default defineComponent({
|
|
|
36
51
|
transfer: {
|
|
37
52
|
type: Boolean,
|
|
38
53
|
default: false
|
|
54
|
+
},
|
|
55
|
+
zIndex: {
|
|
56
|
+
type: Number
|
|
39
57
|
}
|
|
40
58
|
},
|
|
41
|
-
setup(props
|
|
42
|
-
const
|
|
59
|
+
setup(props) {
|
|
60
|
+
const {nextZIndex} = useZIndex();
|
|
61
|
+
const placement = toRef(props, 'placement');
|
|
43
62
|
// @ts-ignore
|
|
44
63
|
const transfer = toRef(props, 'transfer');
|
|
45
64
|
const wrapper = ref<HTMLElement | null>(null);
|
|
46
65
|
const reference = ref<HTMLElement | null>(null);
|
|
47
66
|
const isOpen = ref(false);
|
|
67
|
+
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
68
|
+
|
|
69
|
+
const offset = computed(() => {
|
|
70
|
+
switch(placement.value) {
|
|
71
|
+
case 'top':
|
|
72
|
+
return [0, 8];
|
|
73
|
+
case 'bottom':
|
|
74
|
+
return [0, -8];
|
|
75
|
+
case 'left':
|
|
76
|
+
return [8, 0];
|
|
77
|
+
case 'right':
|
|
78
|
+
return [-8, 0];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
48
81
|
|
|
49
82
|
const { popper, transferTo, updatePopper } = usePopper({
|
|
50
83
|
placement,
|
|
51
84
|
transfer,
|
|
52
85
|
reference,
|
|
53
|
-
wrapper
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const transitionName = computed(() => {
|
|
57
|
-
return `m-transition__${props.transitionName}`;
|
|
86
|
+
wrapper,
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
offset: offset.value
|
|
58
89
|
});
|
|
59
90
|
|
|
60
91
|
const computedClasses = computed(() => {
|
|
61
92
|
return [
|
|
62
|
-
|
|
93
|
+
style.tooltip,
|
|
63
94
|
{
|
|
64
|
-
|
|
95
|
+
[style.reverse]: props.reverse
|
|
65
96
|
}
|
|
66
97
|
]
|
|
67
98
|
});
|
|
68
99
|
|
|
69
|
-
watch(() => isOpen.value, (value) => {
|
|
100
|
+
watch(() => isOpen.value, (value: boolean) => {
|
|
70
101
|
if (value) {
|
|
71
102
|
updatePopper();
|
|
72
103
|
}
|
|
@@ -76,9 +107,9 @@ export default defineComponent({
|
|
|
76
107
|
reference,
|
|
77
108
|
popper,
|
|
78
109
|
transferTo,
|
|
79
|
-
transitionName,
|
|
80
110
|
isOpen,
|
|
81
|
-
computedClasses
|
|
111
|
+
computedClasses,
|
|
112
|
+
zIndex
|
|
82
113
|
}
|
|
83
114
|
}
|
|
84
115
|
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {createVar, style} from '@vanilla-extract/css';
|
|
2
|
+
import { themeVars } from "../../../styles/theme.css";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const vars = {
|
|
6
|
+
backgroundColor: createVar(),
|
|
7
|
+
color: createVar(),
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const tooltip = style({
|
|
11
|
+
vars: {
|
|
12
|
+
[vars.backgroundColor]: themeVars.color.gray[900],
|
|
13
|
+
[vars.color]: themeVars.color.gray[100],
|
|
14
|
+
},
|
|
15
|
+
zIndex: 50,
|
|
16
|
+
transition: 'opacity 0.3s, ease',
|
|
17
|
+
fontSize: "13px",
|
|
18
|
+
fontWeight: 'normal',
|
|
19
|
+
color: vars.color,
|
|
20
|
+
backgroundColor: vars.backgroundColor,
|
|
21
|
+
borderRadius: themeVars.rounded.default,
|
|
22
|
+
padding: `${themeVars.space[1.5]} ${themeVars.space[2]}`,
|
|
23
|
+
pointerEvents: 'none',
|
|
24
|
+
width: 'max-content',
|
|
25
|
+
maxWidth: '300px',
|
|
26
|
+
boxSizing: 'border-box',
|
|
27
|
+
selectors: {
|
|
28
|
+
'&[data-popper-placement^="top"]': {
|
|
29
|
+
margin: `${themeVars.space[1]} 0 ${themeVars.space[3]} 0`,
|
|
30
|
+
},
|
|
31
|
+
'&[data-popper-placement^="bottom"]': {
|
|
32
|
+
margin: `${themeVars.space[3]} 0 ${themeVars.space[1]} 0`,
|
|
33
|
+
},
|
|
34
|
+
'&[data-popper-placement^="left"]': {
|
|
35
|
+
margin: `0 ${themeVars.space[3]} 0 ${themeVars.space[1]}`,
|
|
36
|
+
},
|
|
37
|
+
'&[data-popper-placement^="right"]': {
|
|
38
|
+
margin: `0 ${themeVars.space[1]} 0 ${themeVars.space[3]}`,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const reverse = style({
|
|
44
|
+
vars: {
|
|
45
|
+
[vars.backgroundColor]: themeVars.color.gray[100],
|
|
46
|
+
[vars.color]: themeVars.color.gray[900],
|
|
47
|
+
}
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip.css';
|
|
@@ -1,61 +1,167 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<div
|
|
3
|
+
ref="scroller"
|
|
4
|
+
:class="style.container"
|
|
5
|
+
@scroll.passive="onScroll"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
ref="contentWrapper"
|
|
9
|
+
:style="{ width: `${totalWidth}px`, height: `${totalHeight}px` }"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
:style="{ transform: `translate(${offsetX}px, ${offsetY}px)` }"
|
|
13
|
+
>
|
|
14
|
+
<template v-for="(row, rowIndex) in renderedItems" :key="rowIndex">
|
|
15
|
+
<div
|
|
16
|
+
:style="{ display: 'flex' }"
|
|
17
|
+
>
|
|
18
|
+
<template v-for="(item, colIndex) in row" :key="colIndex">
|
|
19
|
+
<div
|
|
20
|
+
:style="{ width: `${itemWidth}px`, height: `${itemHeight}px` }"
|
|
21
|
+
>
|
|
22
|
+
<slot name="item" :item="item" />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
</div>
|
|
10
28
|
</div>
|
|
29
|
+
</div>
|
|
11
30
|
</template>
|
|
12
31
|
|
|
13
32
|
<script lang="ts">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
import {defineComponent, computed, onMounted, ref, watchEffect, toRef} from 'vue';
|
|
34
|
+
import * as style from "./style";
|
|
35
|
+
export default defineComponent({
|
|
36
|
+
name: "VirtualScroll",
|
|
37
|
+
props: {
|
|
38
|
+
items: {
|
|
39
|
+
type: Array,
|
|
40
|
+
default: () => []
|
|
41
|
+
},
|
|
42
|
+
itemHeight: {
|
|
43
|
+
type: Number,
|
|
44
|
+
default: 30
|
|
45
|
+
},
|
|
46
|
+
itemWidth: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: 140
|
|
49
|
+
},
|
|
50
|
+
buffer: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 5
|
|
53
|
+
},
|
|
54
|
+
delay: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 15
|
|
57
|
+
}
|
|
25
58
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
setup(props, {emit}) {
|
|
60
|
+
const contentWrapper = ref();
|
|
61
|
+
const scroller = ref();
|
|
62
|
+
const scrollerHeight = ref(0);
|
|
63
|
+
const scrollerWidth = ref(0);
|
|
64
|
+
const scrollTop = ref(0);
|
|
65
|
+
const scrollLeft = ref(0);
|
|
66
|
+
const totalHeight = computed(() => props.items.length * props.itemHeight);
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
const totalWidth = computed(() => props.items[0].length * props.itemWidth);
|
|
69
|
+
|
|
70
|
+
const startPosition = computed(() => {
|
|
71
|
+
const row = Math.max(
|
|
72
|
+
0,
|
|
73
|
+
Math.floor(scrollTop.value / props.itemHeight) - 2 * props.buffer
|
|
74
|
+
);
|
|
75
|
+
const col = Math.max(
|
|
76
|
+
0,
|
|
77
|
+
Math.floor(scrollLeft.value / props.itemWidth) - 2 * props.buffer
|
|
78
|
+
);
|
|
79
|
+
return { row, col };
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const endPosition = computed(() => {
|
|
83
|
+
const row = Math.min(
|
|
84
|
+
props.items.length,
|
|
85
|
+
Math.ceil(
|
|
86
|
+
(scrollTop.value + scrollerHeight.value) / props.itemHeight
|
|
87
|
+
) + 2 * props.buffer
|
|
88
|
+
);
|
|
89
|
+
const col = Math.min(
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
props.items[0].length,
|
|
92
|
+
Math.ceil(
|
|
93
|
+
(scrollLeft.value + scrollerWidth.value) / props.itemWidth
|
|
94
|
+
) + 2 * props.buffer
|
|
95
|
+
);
|
|
96
|
+
return { row, col };
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const offsetX = computed(() => {
|
|
100
|
+
return startPosition.value.col * props.itemWidth;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const offsetY = computed(() => {
|
|
104
|
+
return startPosition.value.row * props.itemHeight;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const visibleRows = computed(() =>
|
|
108
|
+
Math.ceil(scrollerHeight.value / props.itemHeight)
|
|
109
|
+
);
|
|
110
|
+
const visibleCols = computed(() =>
|
|
111
|
+
Math.ceil(scrollerWidth.value / props.itemWidth)
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const renderedItems = ref([]);
|
|
115
|
+
|
|
116
|
+
const onScroll = () => {
|
|
117
|
+
scrollTop.value = scroller.value.scrollTop;
|
|
118
|
+
scrollLeft.value = scroller.value.scrollLeft;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
watchEffect(() => {
|
|
122
|
+
const numRows = Math.min(
|
|
123
|
+
props.items.length - startPosition.value.row,
|
|
124
|
+
visibleRows.value + 2 * Math.round(props.buffer + props.buffer / 2)
|
|
125
|
+
);
|
|
126
|
+
const numCols = Math.min(
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
props.items[0].length - startPosition.value.col,
|
|
129
|
+
visibleCols.value + 2 * Math.round(props.buffer + props.buffer / 2)
|
|
130
|
+
);
|
|
131
|
+
const rows = props.items.slice(
|
|
132
|
+
startPosition.value.row,
|
|
133
|
+
startPosition.value.row + numRows
|
|
134
|
+
);
|
|
135
|
+
const slicedRows = rows.map((row) =>
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
row.slice(startPosition.value.col, startPosition.value.col + numCols)
|
|
138
|
+
);
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
renderedItems.value = slicedRows;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
onMounted(() => {
|
|
144
|
+
scrollerHeight.value = scroller.value.clientHeight;
|
|
145
|
+
scrollerWidth.value = scroller.value.clientWidth;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
contentWrapper,
|
|
150
|
+
scroller,
|
|
151
|
+
scrollerHeight,
|
|
152
|
+
scrollerWidth,
|
|
153
|
+
scrollTop,
|
|
154
|
+
scrollLeft,
|
|
155
|
+
totalHeight,
|
|
156
|
+
totalWidth,
|
|
157
|
+
startPosition,
|
|
158
|
+
endPosition,
|
|
159
|
+
renderedItems,
|
|
160
|
+
offsetX,
|
|
161
|
+
offsetY,
|
|
162
|
+
onScroll,
|
|
163
|
+
style
|
|
164
|
+
}
|
|
34
165
|
}
|
|
35
166
|
});
|
|
36
|
-
|
|
37
|
-
const scroller = ref();
|
|
38
|
-
const scrollerHeight = ref(0);
|
|
39
|
-
const scrollTop = ref(0);
|
|
40
|
-
const totalHeight = computed(() => items.value.length * itemHeight.value);
|
|
41
|
-
const startPosition = computed(() =>
|
|
42
|
-
Math.max(0, Math.floor(scrollTop.value / itemHeight.value) - buffer.value)
|
|
43
|
-
);
|
|
44
|
-
const offsetY = computed(() => startPosition.value * itemHeight.value);
|
|
45
|
-
const renderedItems = computed(() => {
|
|
46
|
-
let count =
|
|
47
|
-
Math.ceil(scrollerHeight.value / itemHeight.value) + 2 * buffer.value;
|
|
48
|
-
count = Math.min(items.value.length - startPosition.value, count);
|
|
49
|
-
return items.value.slice(startPosition.value, startPosition.value + count);
|
|
50
|
-
});
|
|
51
|
-
const onScroll = (e: Event) => {
|
|
52
|
-
requestAnimationFrame(() => (scrollTop.value = (e.target as HTMLElement).scrollTop));
|
|
53
|
-
};
|
|
54
|
-
const observer = new ResizeObserver((entries) =>
|
|
55
|
-
entries.forEach((el) => (scrollerHeight.value = el.contentRect.height))
|
|
56
|
-
);
|
|
57
|
-
onMounted(() => {
|
|
58
|
-
observer.observe(scroller.value);
|
|
59
|
-
scrollerHeight.value = scroller.value.offsetHeight;
|
|
60
|
-
});
|
|
61
|
-
</script>
|
|
167
|
+
</script>
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
default: 50
|
|
10
|
-
},
|
|
11
|
-
buffer: {
|
|
12
|
-
type: Number,
|
|
13
|
-
default: 3
|
|
14
|
-
},
|
|
15
|
-
pageHeight: {
|
|
16
|
-
type: Number,
|
|
17
|
-
default: 400
|
|
18
|
-
}
|
|
19
|
-
})
|
|
2
|
+
import {ref} from "vue";
|
|
3
|
+
|
|
4
|
+
const items = ref(
|
|
5
|
+
Array.from({ length: 1000 }, (_, i) =>
|
|
6
|
+
Array.from({ length: 1000 }, (_, j) => i + j + 1)
|
|
7
|
+
)
|
|
8
|
+
);
|
|
20
9
|
</script>
|
|
21
10
|
|
|
22
11
|
<template>
|
|
23
12
|
<div>
|
|
24
13
|
<MVirtualScroll
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}"
|
|
14
|
+
:items="items"
|
|
15
|
+
:item-size="[50, 100]"
|
|
16
|
+
autoSize
|
|
17
|
+
orientation="both"
|
|
18
|
+
style="width: 970px; height: 600px; overflow: auto"
|
|
31
19
|
>
|
|
32
|
-
<
|
|
33
|
-
{{ item
|
|
34
|
-
</
|
|
20
|
+
<template v-slot:item="{ item }">
|
|
21
|
+
{{ item }}
|
|
22
|
+
</template>
|
|
35
23
|
</MVirtualScroll>
|
|
36
24
|
</div>
|
|
37
25
|
</template>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.odd {
|
|
29
|
+
background-color: #f5f5f5;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -5,27 +5,11 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
createStory
|
|
8
|
-
} from "
|
|
8
|
+
} from "../../../__storybook__";
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
component: MVirtualScroll,
|
|
12
12
|
title: 'Components/VirtualScroll'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
for (let i = 0; i < 1000; i++) {
|
|
18
|
-
items.push({
|
|
19
|
-
id: i + 1,
|
|
20
|
-
name: 'Some name here ' + (i + 1),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const Basic = createStory(MVirtualScrollBasic).bind({});
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
Basic.args = {
|
|
27
|
-
items: items,
|
|
28
|
-
itemHeight: 50,
|
|
29
|
-
buffer: 3,
|
|
30
|
-
pageHeight: 500,
|
|
31
|
-
};
|
|
15
|
+
export const Basic = createStory(MVirtualScrollBasic);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {globalStyle, style} from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
export const container = style({
|
|
4
|
+
overflow: 'auto',
|
|
5
|
+
willChange: 'transform',
|
|
6
|
+
contain: 'strict'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
globalStyle(`${container} > div`, {
|
|
10
|
+
overflow: 'hidden',
|
|
11
|
+
willChange: 'transform'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
globalStyle(`${container} > div > div`, {
|
|
15
|
+
willChange: 'transform',
|
|
16
|
+
backfaceVisibility: 'hidden'
|
|
17
|
+
});
|
|
18
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './VirtualScroll.css';
|
|
@@ -74,7 +74,7 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
|
|
|
74
74
|
return true;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const inputListeners = withListeners ? computed(() => {
|
|
78
78
|
return {
|
|
79
79
|
blur: (event: Event) => emit('blur', event),
|
|
80
80
|
focus: (event: Event) => emit('focus', event),
|
|
@@ -104,7 +104,7 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
|
|
|
104
104
|
isFirstValidation,
|
|
105
105
|
formError,
|
|
106
106
|
insideForm: form.insideForm,
|
|
107
|
-
|
|
107
|
+
inputListeners,
|
|
108
108
|
reset,
|
|
109
109
|
validate,
|
|
110
110
|
setError,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
export interface InteractiveProps {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useInteractive = (
|
|
9
|
+
el: Ref<HTMLElement | null>,
|
|
10
|
+
) => {
|
|
11
|
+
return {
|
|
12
|
+
focus: () => el.value?.focus?.(),
|
|
13
|
+
blur: () => el.value?.blur?.(),
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
useInteractive.props = () => ({
|
|
18
|
+
disabled: Boolean,
|
|
19
|
+
loading: Boolean,
|
|
20
|
+
} as const);
|
|
@@ -50,7 +50,7 @@ export function usePopper(initialOptions: UsePopperOptions) {
|
|
|
50
50
|
|
|
51
51
|
const reference: Ref<HTMLElement | null | undefined> = (initialOptions.reference as any) ?? ref(null);
|
|
52
52
|
const popper: Ref<HTMLElement | null | undefined> = initialOptions.popper ?? ref(null);
|
|
53
|
-
const transferTo: Ref<String> = ref('');
|
|
53
|
+
const transferTo: Ref<String> = ref('body');
|
|
54
54
|
|
|
55
55
|
const options: {
|
|
56
56
|
placement: Placement,
|